Skip to content

Image

Type
Class
Namespace
craft\web\twig\variables
Inherits
craft\web\twig\variables\Image
Since
3.0.0

Class Image variable.

View source

Protected Properties

PropertyDescription
pathstring, null
sizearray, null
urlstring, null

path

Type
string, null
Default value
null

View source

size

Type
array, null
Default value
null

View source

url

Type
string, null
Default value
null

View source

Public Methods

MethodDescription
__construct()Constructor
getContents()Returns the file’s contents.
getDataUrl()Returns a base64-encoded data URL for the image.
getHeight()Returns the image's height.
getMimeType()Returns the file’s MIME type, if it can be determined.
getPath()Returns the image’s path.
getSize()Returns an array of the width and height of the image.
getUrl()Returns the image's URL.
getWidth()Returns the image's width.

__construct()

Constructor

View source

Arguments

getContents()

Since
3.7.27

Returns the file’s contents.

View source

Returns

string

getDataUrl()

Since
3.7.27

Returns a base64-encoded data URL for the image.

View source

Returns

string

getHeight()

Returns the image's height.

View source

Returns

integer

getMimeType()

Since
3.7.27

Returns the file’s MIME type, if it can be determined.

View source

Returns

string, null

getPath()

Since
3.7.27

Returns the image’s path.

View source

Returns

string

getSize()

Returns an array of the width and height of the image.

View source

Returns

array

getUrl()

Returns the image's URL.

View source

Returns

string

getWidth()

Returns the image's width.

View source

Returns

integer