This is quick test to see what could be done to automatically generate a thumbnail image from the product one. It's not complete (it only works with JPG product images) and requires your product images to be in the Site folder but should give some idea of what could be done.
It's a block of code that replaces the Standard Product Image layout and contains an extra block of PHP that creates a new image t_<ProductImageFileName> scaled down to a width of 50px.
At the moment this image is displayed (necessary so that Actinic will upload it), but all you need to do is add some CSS to the <img...> tag to make this hidden and it will still be uploaded.
Now, wherever you are able to display a Product Image you can also display
<img src="t_<actinic:variable name="ProductImageFileName" />" />
Code like this could also be used to allow you to use arbitrary sized product images, which are then automatically scaled down to fit the site requirements.
It's a block of code that replaces the Standard Product Image layout and contains an extra block of PHP that creates a new image t_<ProductImageFileName> scaled down to a width of 50px.
Code:
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsPopUpDisplayedByImage%22%20%2f%3e"> <actinic:block if="%3cactinic%3avariable%20name%3d%22ExtendedInformationType%22%20%2f%3e%20%3d%3d%20%22Opens%20in%20a%20Pop%2dUp%20Window%22"> <a href="javascript:ShowPopUp('<actinic:variable name=ExtendedInfoPageEncoded />',<actinic:variable name="ExtInfoWindowWidth" />,<actinic:variable name="ExtInfoWindowHeight" />);"> </actinic:block> <actinic:block if="%3cactinic%3avariable%20name%3d%22ExtendedInformationType%22%20%2f%3e%20%3d%3d%20%22Opens%20in%20the%20Same%20Window%22" > <a href="<actinic:variable name="ExtendedInfoPageName" />"> </actinic:block> </actinic:block> <actinic:block if="%3cactinic%3avariable%20name%3d%22IsProductImageDisplayed%22%20%2f%3e"> <img src="<actinic:variable name="ProductImageFileName" />" border="0" width="<actinic:variable name="ProductImageWidth" />" height="<actinic:variable name="ProductImageHeight" />" alt="<actinic:variable name="ProductName" />" /> <actinic:block php="true" > // START Create a thumbnail image t_ProductImageFileName $sOriginalImageName = '<actinic:variable encoding="perl" name="ProductImageFileName" selectable="false" />'; $sThumbImageName = 't_' . $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 = 50; $t_height = $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 "<br><img src=\"$sThumbImageName\" width=\"$t_width\" height=\"$t_height\" border=0 />"; } imagedestroy($thumbimage); } imagedestroy($image); // END Create a thumbnail image t_ProductImageFileName </actinic:block> </actinic:block> <actinic:block if="%3cactinic%3avariable%20name%3d%22IsProductImageDisplayed%22%20%2f%3e%20%3d%3d%20False"> <img src="<actinic:variable name="DefaultProductImage" />" border="0" alt="<actinic:variable name="ProductName" />" /> </actinic:block> <actinic:block if="%3cactinic%3avariable%20name%3d%22IsPopUpDisplayedByImage%22%20%2f%3e"> </a> </actinic:block>
Now, wherever you are able to display a Product Image you can also display
<img src="t_<actinic:variable name="ProductImageFileName" />" />
Code like this could also be used to allow you to use arbitrary sized product images, which are then automatically scaled down to fit the site requirements.
Comment