Image
This control allows user to select an image file on server.
On this page
XML Configuration
Element name: image
| Attribute Name | Type | Required | Default | Description |
| name | String | Yes | n / a | Variable name of user control. Which you can use whether in your template file, or in your extension. |
| friendlyName | String | No | n / a |
Control's friendly name displayed in CMS backend. |
| maxwidth | Integer | No | 0 | Sets maximum width of image. |
| maxheight |
Integer |
No |
0 |
Sets maximum height of image. |
| resizeMethod | String ('none', 'scale', 'background', 'crop') |
No | none |
If specified, resizes the image to the size that is specified by maxwidth and maxheight parameters, according to specified method. |
| bgcolor |
String |
No |
#ffffff |
In case resizeMethod is "background" you can specify background color. By default the color is white #ffffff. |
Resize methods (resizeMethod attribute)
"scale" - resizes image with keeping original proportions. For example if original size is 200x133 and maximum size is 100x100, then maximum possible size to fit in 100x100 will be 100x66.

If you specify 0 (zero) as maximum size for one the sides, this means, that this side can be unlimited wide (or high). For example if you specify maxwidth=0 and maxheight=100, result size will be 150x100.
"background" - resizes image to specified size. To keep original proportions, it adds a background color to image. For example if original size is 200x133 and desired size is 100x100, then first, image will be resizes to 100x66 and then 34 pixels (17 at top, 17 at bottom) will fullfill the restarea of the image. By default background color is white, but you can specify it in hex form in bgcolor attribute (i.e. #999999).

"crop" - resizes image to specified size and crops it if neccessary. For example if original image size is 200x133 and desired size is 100x100, then first image will be resized to 150x100 and then 25px from both sides (left and right) will be cropped.

<userControls>
<image name="myimage" friendlyName="My image" maxwidth="100"
maxheight="100"></image>
</userControls>
PHP Class
Class name: UC_image
Fields
Background color in a hex format. Requried, when resizeMethod is set to "background"
- Type
- string
Maximum height of image (if image is bigger, then it will be rescaled). 0 = no limit.
- Type
- integer
Maximum width of image (if image is bigger, then it will be rescaled). 0 = no limit.
- Type
- integer
Resize method, possible values are: "scale" - scales image with keeping of original proportions, "background" - resizes image to fixed size with adding background, "crop" - resizes image to desired size and adjusts proporties by cropping the image
- Type
- string
Methods
Returns path to image. If image was rescaled, returns path to rescaled temporary file.
Sets image value
- Parameters:
-
string/array$value - path to image. In case you want to specify image position, you have to pass an associative array with following structure
$value["position"] = IMAGE_POSITION ("in-text-tl", "in-text-tr", "near-text-tc", "near-text-bc", "near-text-tl", "near-text-tr", "behind-text-tl")
$value["source"] = PATH_IMAGE_IN_DATA_FOLDER