Image
The Image object may be used to calculate resize URLs for images within your Media Library, but does not manipulate the original file. This object is provided
as an alternative to the <ev:img> tag, allowing
programmatic calculations of resize URLs.
Instantiation
You can instantiate a new Image object by supplying a string of the image url:
<?ev
// new Image() using a url
var logo = new Image('/portal/web/gateway/content/images/logo.png');
?>
Note: The image must be relative to the site. The image can be within your theme, or in your content media library.
When you instantiate a new Image object you can also pass in the width and/or height by supplying a number:
<?ev
// new Image() with a width
var logo = new Image('/portal/web/gateway/content/images/logo.png', 100);
// new Image() with a height
var logo = new Image('/portal/web/gateway/content/images/logo.png', null, 100);
// new Image() with a width and height
var logo = new Image('/portal/web/gateway/content/images/logo.png', 100, 100);
?>
| Construct parameters |
|---|
urlPath
String |
Url
If the image supplied is a valid image path, the Image object will return the image object.
|
width
Number | null
(optional)
If you supply a width along with the image, the Image object will return a resized image object.
|
height
Number | null
(optional)
If you supply a height along with the image, the Image object will return a resized image object.
|
maxWidth
Number | null
(optional)
If you supply a max-width along with the image, the Image object will return a resized image object.
|
maxHeight
Number | null
(optional)
If you supply a max-height along with the image, the Image object will return a resized image object.
|
| Properties |
|---|
width
Number | null
Width property is null if no width is set, otherwise returns the Number object. |
height
Number | null
Height property is null if no height is set, otherwise returns the Number object. |
maxwidth
Number | null
Max-width property is null if no max-width is set, otherwise returns the Number object. |
maxheight
Number | null
Max-height property is null if no max-height is set, otherwise returns the Number object. |
| Methods |
|---|
width(Number:value)
Image
Set the width you wish to resize your image too.
|
height(Number:value)
Image
Set the height you wish to resize your image too.
|
maxwidth(Number:value)
Image
Set the max-width you wish to resize your image too.
|
maxheight(Number:value)
Image
Set the max-height you wish to resize your image too.
|
size(String:dimensions)
Deprecated, please use width and height methods. |
src(String:urlPath)
Image
Set the source image of the image you wish to resize.
|
toString()
String
This method returns the relative path to the resized image as a string.
|
toUrl()
Url
This method returns the url object of the image.
|