1

This code will display images within an email from the server. It will display an image with a choice of file extension which can be expanded to fit your needs.

this code was originally developed for a emailing system where the images to be displayed where uploaded by the user.

Votes + Comments
Thanks for sharing!
$image = "";
$broad_img1= "";
//this has to be set like this as if file exist does not work with absolute paths
$path= 'http://wwwyour web site.com';
//this is the directory where the images are stored
$web_image_folder = 'image/thumbs';
$exts = array('jpg', 'png', 'gif', 'jpeg');
//the name of the file on the server
$image_name = 'thumb_image1';


// check for each extension
foreach($exts as $ext) {
   if (file_exists($web_image_folder.'/'.$image_name.'.'.$ext)) {
     $image = $image_name.'.'.$ext;
   }
}

// check if we have an image
if ($image != "") {
    // ok we have the image now store it in a variable
    $broad_img1='<img src="' . $path."/".$web_image_folder."/".$image . '" />';
} else {
    // error, we can't find the image.
}
2
Contributors
1
Reply
13
Views
9 Years
Discussion Span
Last Post by LastMitch
0

This code will display images within an email from the server. It will display an image with a choice of file extension which can be expanded to fit your needs.

It's a bit of a challenge to display an image within an email without additional code (email). Overall, it was good. Thanks for sharing.

But it does work (without the email) and it does display the the image:

2ce9b3a9f054fa781c8be9df5e42ea00

Edited by LastMitch

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.