jasonhardwick Posted May 9, 2008 Share Posted May 9, 2008 I posted this question earlier but still no luck. for some reason my echo on the last line of the code doesn't produce an image and i'm not sure why any ideas. thanks <?php $img_path = "file/".$rows ['file']; $image_t = getimagesize($img_path); imageResize($image_t[0], $image_t[1], 100); function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } echo "<img src=$image_t>"; ?> Link to comment https://forums.phpfreaks.com/topic/104850-solved-image-not-displaying/ Share on other sites More sharing options...
thebadbad Posted May 9, 2008 Share Posted May 9, 2008 The source to the image isn't $image_t, since that contains the array returned by getimagesize(). Also, you're not 'catching' the returned string of your function. Is this what you want?: <?php $img_path = "file/".$rows ['file']; $image_t = getimagesize($img_path); //edited this $wh = imageResize($image_t[0], $image_t[1], 100); function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } //and this echo "<img src=\"$img_path\" $wh />"; ?> Link to comment https://forums.phpfreaks.com/topic/104850-solved-image-not-displaying/#findComment-536662 Share on other sites More sharing options...
jasonhardwick Posted May 9, 2008 Author Share Posted May 9, 2008 Thanks That worked. Link to comment https://forums.phpfreaks.com/topic/104850-solved-image-not-displaying/#findComment-536664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.