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
Property | Description |
---|---|
path | string (opens new window), null (opens new window) |
size | array (opens new window), null (opens new window) |
url | string (opens new window), null (opens new window) |
# 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
$path
(string (opens new window))$url
(string (opens new window))
# getContents()
- Since
- 3.7.27
Returns the file’s contents.
View source (opens new window)
Returns
# getDataUrl()
- Since
- 3.7.27
Returns a base64-encoded data URL (opens new window) for the image.
View source (opens new window)
Returns
# getHeight()
Returns the image's height.
View source (opens new window)
Returns
# 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
# getSize()
Returns an array of the width and height of the image.
View source (opens new window)
Returns
# getUrl()
Returns the image's URL.
View source (opens new window)
Returns
# getWidth()
Returns the image's width.
View source (opens new window)
Returns
← CraftVariable Io →