| All our CubeCart V4 skins now feature dynamic image scaling. This post contains information on how to effectively make use of this feature.
What's Dynamic Image Scaling?
Our dynamic image scaling script is included in all of our CubeCart V4 skins. The script allows you to scale any image on demand. You don't need to manually resize any images. You simply specify the image you want to scale along with some parameters. Please note that you can only reduce the size of an image. It is not possible to create a larger image from a smaller image. For this reason, it is recommended that you set the "Max Image Size" and "Thumbnail Size" settings in your CubeCart's administration panel to large values.
I have already uploaded images to my store
If you uploaded images to your store via the administration panel, your images will have been resized according to the "Max Image Size" and "Thumbnail Size" settings that you had at the time. Although it is possible to resize your thumbnails via the administration panel, it is not possible to restore the product image to its full size.
If you uploaded your images via FTP, CubeCart will not have resized your images.
Changing the "Max Image Size" and "Thumbnail Size" Settings
You'll first need to login to your CubeCart store's administration panel. Once your're inside, select "General Settings" from the left hand navigation pane. Scroll down untill you find the "GD Settings" section. Enter the desired values for the "Max Image Size" and "Thumbnail Size" settings. Please see the recommended settings below. Finally select the "Update Settings" button.
We recommend that you enter the following values:
- Max Image Size: 800
- Thumbnail Size: 300
Script Parameters
The Dynamic Image Scaling script can take the following parameters:
| Parameter | Data Type | Example |
| Product ID |
Integer |
getImg.php?id=1 |
| Image Path |
String |
getImg.php?src=/store/images/uploads/file.jpg |
| Width |
Integer |
getImg.php?width=300 |
| Height |
Integer |
getImg.php?height=200 |
| Fill Dimensions |
Boolean |
getImg.php?fill=1 |
| JPEG Sharpening |
Boolean |
getImg.php?sharpen=1 |
| Background Color |
HEX |
getImg.php?color=FFFFFF |
| Reflection |
Boolean |
getImg.php?reflect=1 |
| Cache |
Boolean |
getImg.php?nocache=1 |
| JPEG Quality |
Integer |
getImg.php?quality=50 |
| Padding |
Integer |
getImg.php?padding=20 |
Please note that you must specify either a Product ID or an Image Path. All other parameters are optional. Furthermore, the JPEG Sharpening, JPEG Quality, Background Color, Padding and Reflection parameters are not completely stable. However, in the majority of cases, you will not need to specify these parameters. You can find below a short description for each parameter:
| Parameter | Description |
| Product ID |
Loads the primary image assigned to the product with the specified Product ID. If possible, use the "Image Path" property instead since this will reduce the number of SQL queries and hence the load on your server. |
Image Path
|
Loads the image at the specified path. Please note that this path should be relative to your CubeCart store's root directory. Example: /images/uploads/image.png
|
| Width |
The scaled image's width boundary condition. Please note that this property can be modified by using the "Fill Dimensions" parameter.
|
| Height |
The scaled image's height boundary condition. Please note that this property can be modified by using the "Fill Dimensions" parameter. |
Fill Dimensions
|
If enabled, the image will be scaled and cropped to completely fill the specified width and height parameters. Note that both the source images width and height properties must be larger than the specified width and height parameters.
|
JPEG Sharpening
|
Attempt to sharpen the resized JPEG image. Please note that this parameter is not stable.
|
Background Color
|
Sets the background color for transparent PNGs and GIFs. This value can also be used to manipulate reflections. Please note that this parameter is not stable. |
| Reflection |
Produce a reflection of the image. When enabled, the image and its reflection is resized to the specified width and height boundary conditions. Please note that this parameter is not stable. |
| Cache |
If you do not want the resized image to be loaded from the cache, you can specify the nocache parameter. This should only really be used for debugging. All resized images are cached as standard to reduce the load on your server.
|
| Quality |
Sets the quality of JPEG images. You should only specify a value from 1 - 100. A low value will cause a reduction in the image quality but also a reduction in the file size. By default, the quality is set to 80 for all JEPG images. This setting does not apply to other image types.
|
| Padding |
Adds a border around the image. You will need to specify the size in pixels. In most cases, it would be better to do this using CSS.
|
Are there any known bugs or parameter incompatibilities?
Some of the parameters listed above are not stable and should only be used on a case-by-case basis. It is not recommended that you apply the experimental properties to image paths in your template files. The following list details the known incompatibilities:
- The Padding property cannot be used in conjunction with the Fill property
- The Fill property cannot be used in conjunction with the Reflect property.
- The Fill property sometimes fails when the specified dimensions are larger than the source image
|