Core classFiles\Classes

TransformedImage

Image class that represents an image after it has been transformed

Files\Classes\TransformedImage

Properties 8

Take no arguments.

# getPath()
string
Get the path for this image
# getMimeType()
string
Get the mime type of the image
# getFormat()
string
Get the format of the image
# isBlank()
bool
Return the information that this is not a blank image
# getType()
string
Get the type of the image. Always returns "image".
# getWidth()
int
Get the width of the image in pixels
# getHeight()
int
Get the height of the image in pixels
# getName()
?string
Get the name of the image revision - this is usually used as ALT text

Methods 4

Take arguments. The API serialises only getters that need none.

# toFormat(string $targetFormat, ?array $sourceFormats)
TransformedImage
Convert the image to the target format. Optionally only performs the transformation if the source format is
contained in the provided formats. Using this method, it is possible to convert images matching a certain format
(like png and gif) to the target formats (like jpeg or webp), while leaving other images untouched.
# toOptimizedFormat(string $targetFormat)
TransformedImage
Get the image in an optimized format. Only converts the image if it does not already have the target format,
and if conversion is possible. SVG images are never converted to other formats.
# getHtml(array $attributes)
string
Get the html image tag for this image
# getResized(?int $width, ?int $height, string $resizeStrategy)
TransformedImage
Get a resized version of the active revision of the image Tries to fetch the image first, otherwise will create and return it Will save the resized copy and potentially also the current image, if the dimensions were not determined previously