I made a post here a while ago about this topic, but I've finally been able to put some time into it again, and I've made some progress. I'm up against another wall, though.
I have a php file that creates the thumbnail, and I call it in the <img> tag. I am calling the script multiple times on the page. Whether it shows the image correctly or shows a broken link seems to be completely random, even though the src url always shows the thumbnail correctly.
The code that I use to call the script is as follows:
The script that actually generates the thumbnail is as follows:
I have seen pages where this strategy works consistantly. I just haven't been able to find where my script breaks down. Like I say, when I access the script directly with the url, it works every time.
I have a php file that creates the thumbnail, and I call it in the <img> tag. I am calling the script multiple times on the page. Whether it shows the image correctly or shows a broken link seems to be completely random, even though the src url always shows the thumbnail correctly.
The code that I use to call the script is as follows:
Code:
echo "<img width = '96' height = '130' src = 'scripts/functions/thumb.php?upc=$upc' alt = 'IMG: {$title}'>";
The script that actually generates the thumbnail is as follows:
Code:
<?php
ob_start();
$upc = $_GET['upc'];
$turl = '[URL unfurl="true"]http://m4s-s1/images/';[/URL]
$tfilename = $upc.'_a.jpg';
$tfilepath = $turl.$tfilename;
list($width_orig, $height_orig) = getimagesize($tfilepath);
$image = imagecreatefromjpeg($tfilepath);
$image_p = imagecreatetruecolor(96, 130);
$width = 96;
$height = 130;
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
header("Content-type: image/jpeg");
$output .= imagejpeg($image_p);
?>
I have seen pages where this strategy works consistantly. I just haven't been able to find where my script breaks down. Like I say, when I access the script directly with the url, it works every time.