Quicksearch
Archives
Categories
Syndicate This Blog
Blog Administration
Automatically Rescale Your Images to a Certain Size In Actinic software
Actinic Ecommerce Shopping Cart Software
Sunday, September 24. 2006
Automatically Rescale Your Images to a Certain Size In Actinic software
This is so incrediably useful that its a shame to have this hidden in the "advanced Users Guide"
This is a handy PHP expression that will dynamically rescale your product images and display them in their new size. This resizing happens on the desktop PC, and the new files will be uploaded to the store with the other image files. The names of the new image files will all start with 't_'.
In order for it to work, your current images must be in .jpg format and they must be saved in your 'Site' folder (usually 'Site1').
In the 'Design' tab, click on a product image. You should be in a layout called 'Standard Product Image'.
Replace the entire contents of the layout with the following:
<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">
<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 = 100;
$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\" />";
}
}
// 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>
To use a different width, change the value in this line to a larger/smaller value:
$t_width = 100;
You can now use the following line to include the rescaled product images elsewhere in your product layout, or in the best seller/new products/related items/also bought lists:
<img src="t_<actinic:variable name="ProductImageFileName" />" />
With grateful thanks to Norman Rouxel (http://www.drillpine.biz/) for this solution.













