Image
Extends Object.
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', '', 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
(optional)
If you supply a width along with the image, the Image object will return a resized image object.
|
height
Number
(optional)
If you supply a height along with the image, the Image object will return a resized image object.
|
maxWidth
Number
(optional)
If you supply a max-width along with the image, the Image object will return a resized image object.
|
maxHeight
Number
(optional)
If you supply a max-height along with the image, the Image object will return a resized image object.
|
Properties |
---|
width
Number
Width property is null if no width is set, otherwise returns the Number object. |
height
Number
Height property is null if no height is set, otherwise returns the Number object. |
maxwidth
Number
Max-width property is null if no max-width is set, otherwise returns the Number object. |
maxheight
Number
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)
Image
Set the width and height you wish to resize your image too. The string is expected to contain two numbers split by a 'x'.
|
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.
|