Image

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

Class Image variable.

View source (opens new window)

# Protected Properties

# path

Type
string (opens new window), null (opens new window)
Default value
null

View source (opens new window)

# size

Type
array (opens new window), null (opens new window)
Default value
null

View source (opens new window)

# url

Type
string (opens new window), null (opens new window)
Default value
null

View source (opens new window)

# Public Methods

Method Description
__construct() Constructor
getContents() Returns the file’s contents.
getDataUrl() Returns a base64-encoded data URL (opens new window) 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 (opens new window)

Arguments

# getContents()

Since
3.7.27

Returns the file’s contents.

View source (opens new window)

Returns

string (opens new window)

# getDataUrl()

Since
3.7.27

Returns a base64-encoded data URL (opens new window) for the image.

View source (opens new window)

Returns

string (opens new window)

# getHeight()

Returns the image's height.

View source (opens new window)

Returns

integer (opens new window)

# getMimeType()

Since
3.7.27

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

View source (opens new window)

Returns

string (opens new window), null (opens new window)

# getPath()

Since
3.7.27

Returns the image’s path.

View source (opens new window)

Returns

string (opens new window)

# getSize()

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

View source (opens new window)

Returns

array (opens new window)

# getUrl()

Returns the image's URL.

View source (opens new window)

Returns

string (opens new window)

# getWidth()

Returns the image's width.

View source (opens new window)

Returns

integer (opens new window)