Hi All,
Hope someone can help.
Could someone look at the code below and tell me if there is a reason I get "thumbnail creation error opeing:../imagefilename.jpg in the preview (and the thumbnail no longer gets produced obviously).
I am using a single product page (SSP) layout using the extended info method.
Had everything working fine including image resizing from ProductImageFileName but a request from the client meant that the product list needed to use a differnt image though the image on the SPP could still generate from a larger image that gets used in a lightbox when user clicks to enlarge.
To accomodate this i felt it more understandable for the client that the file requested in the product image field would be used for the product list and that I could use the extended info image field to use for the lightbox image and the generate "thumbnail" which would be used for the main product image on the SPP.
Any help appreciated,
Cheers
Lee
Hope someone can help.
Could someone look at the code below and tell me if there is a reason I get "thumbnail creation error opeing:../imagefilename.jpg in the preview (and the thumbnail no longer gets produced obviously).
<p><actinic:block if="%3cactinic%3avariable%20name%3d%22IsPopUpDisplayedByImage%22%20%2f%3e" >
<a href="<actinic:variable name="ExtendedInfoImage" />" rel="images" title="<actinic:variable name="ProductName" />">
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsExtendedImageSpecified%22%20%2f%3e" >
<actinic:block php="true" >
// START Create a thumbnail image t_ProductImageFileName
$sOriginalImageName = str_replace('\\','/', '<actinic:variable encoding="perl" name="ExtendedInfoImage" selectable="false" />');
$nScaledWidth = <actinic:variable encoding="perl" name="ProductImageScaledWidth" selectable="false" />;
$sThumbImageName = 'thumbnails/t_' . basename($sOriginalImageName);
$image = @imagecreatefromjpeg($sOriginalImageName); /* Attempt to open */
if (!$image)
{ /* See if it failed */
echo "<br><font color=red>Thumbnail creation error opening: $sOriginalImageName </font>";
}
else
{
// Get new dimensions
$width = imagesx($image);
$height = imagesy($image);
$t_width = $nScaledWidth;
$t_height = round($height * ($t_width / $width));
// Resample
$thumbimage = imagecreatetruecolor($t_width, $t_height);
imagecopyresampled($thumbimage, $image, 0, 0, 0, 0, $t_width, $t_height, $width, $height);
if ( ! imagejpeg($thumbimage, $sThumbImageName) )
{
echo "<font color=red>Thumbnail image creation failed: $sThumbImageName </font><br>";
}
else
{
echo "<img src=\"$sThumbImageName\" width=\"$t_width\" height=\"$t_height\" border=\"0\"";
echo " alt=\"<actinic:variable name="ProductName" encoding="strip"/>\" />";
}
}
// END Create a thumbnail image t_ProductImageFileName
</actinic:block>
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsExtendedImageSpecified%22%20%2f%3e%20%3d%3d%20False" >
<img src="<actinic:variable name="DefaultProductImage" />"
border="0"
alt="<actinic:variable name="ProductName" encoding="strip"/>" />
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsPopUpDisplayedByImage%22%20%2f%3e" >
<span class="zoom"></span></a>
</actinic:block>
</p>
<a href="<actinic:variable name="ExtendedInfoImage" />" rel="images" title="<actinic:variable name="ProductName" />">
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsExtendedImageSpecified%22%20%2f%3e" >
<actinic:block php="true" >
// START Create a thumbnail image t_ProductImageFileName
$sOriginalImageName = str_replace('\\','/', '<actinic:variable encoding="perl" name="ExtendedInfoImage" selectable="false" />');
$nScaledWidth = <actinic:variable encoding="perl" name="ProductImageScaledWidth" selectable="false" />;
$sThumbImageName = 'thumbnails/t_' . basename($sOriginalImageName);
$image = @imagecreatefromjpeg($sOriginalImageName); /* Attempt to open */
if (!$image)
{ /* See if it failed */
echo "<br><font color=red>Thumbnail creation error opening: $sOriginalImageName </font>";
}
else
{
// Get new dimensions
$width = imagesx($image);
$height = imagesy($image);
$t_width = $nScaledWidth;
$t_height = round($height * ($t_width / $width));
// Resample
$thumbimage = imagecreatetruecolor($t_width, $t_height);
imagecopyresampled($thumbimage, $image, 0, 0, 0, 0, $t_width, $t_height, $width, $height);
if ( ! imagejpeg($thumbimage, $sThumbImageName) )
{
echo "<font color=red>Thumbnail image creation failed: $sThumbImageName </font><br>";
}
else
{
echo "<img src=\"$sThumbImageName\" width=\"$t_width\" height=\"$t_height\" border=\"0\"";
echo " alt=\"<actinic:variable name="ProductName" encoding="strip"/>\" />";
}
}
// END Create a thumbnail image t_ProductImageFileName
</actinic:block>
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsExtendedImageSpecified%22%20%2f%3e%20%3d%3d%20False" >
<img src="<actinic:variable name="DefaultProductImage" />"
border="0"
alt="<actinic:variable name="ProductName" encoding="strip"/>" />
</actinic:block>
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsPopUpDisplayedByImage%22%20%2f%3e" >
<span class="zoom"></span></a>
</actinic:block>
</p>
Had everything working fine including image resizing from ProductImageFileName but a request from the client meant that the product list needed to use a differnt image though the image on the SPP could still generate from a larger image that gets used in a lightbox when user clicks to enlarge.
To accomodate this i felt it more understandable for the client that the file requested in the product image field would be used for the product list and that I could use the extended info image field to use for the lightbox image and the generate "thumbnail" which would be used for the main product image on the SPP.
Any help appreciated,
Cheers
Lee
Comment