ImageMediaTrait
Trait ImageMediaTrait
Table of Contents
Properties
- $magic_actions : array<string|int, mixed>
- $magic_resize_actions : array<string|int, mixed>
- $aspect_ratio : bool
- $auto_sizes : bool
- $debug_watermarked : bool
- $default_quality : int
- $format : string
- $image : ImageFile|null
- $quality : int
- $retina_scale : int
- $sizes : string
- $watermark : bool
Methods
- cache() : $this
- Simply processes with no extra methods. Useful for triggering events.
- clearAlternatives() : mixed
- Clear out the alternatives.
- derivatives() : $this
- Generate alternative image widths, using either an array of integers, or a min width, a max width, and a step parameter to fill out the necessary widths. Existing image alternatives won't be overwritten.
- filter() : $this
- Filter image by using user defined filter parameters.
- format() : $this
- Sets image output format.
- getImagePrettyName() : string
- height() : $this
- Allows to set the height attribute from Markdown or Twig Examples:     {{ page.media['myimg.png'].width().height().html }} {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }}
- higherQualityAlternative() : ImageMediaInterface|$this
- Return the image higher quality version
- quality() : int|$this
- Sets or gets the quality of the image
- setImagePrettyName() : mixed
- Allows the ability to override the image's pretty name stored in cache
- sizes() : string
- Set or get sizes parameter for srcset media action
- width() : $this
- Allows to set the width attribute from Markdown or Twig Examples:     {{ page.media['myimg.png'].width().height().html }} {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }}
- image() : $this
- Gets medium image, resets image manipulation operations.
- saveImage() : string
- Save the image with cache.
Properties
$magic_actions
public
static array<string|int, mixed>
$magic_actions
= ['resize', 'forceResize', 'cropResize', 'crop', 'zoomCrop', 'negate', 'brightness', 'contrast', 'grayscale', 'emboss', 'smooth', 'sharp', 'edge', 'colorize', 'sepia', 'enableProgressive', 'rotate', 'flip', 'fixOrientation', 'gaussianBlur', 'format', 'create', 'fill', 'merge']
$magic_resize_actions
public
static array<string|int, mixed>
$magic_resize_actions
= ['resize' => [0, 1], 'forceResize' => [0, 1], 'cropResize' => [0, 1], 'crop' => [0, 1, 2, 3], 'zoomCrop' => [0, 1]]
$aspect_ratio
protected
bool
$aspect_ratio
$auto_sizes
protected
bool
$auto_sizes
$debug_watermarked
protected
bool
$debug_watermarked
= false
$default_quality
protected
int
$default_quality
$format
protected
string
$format
= 'guess'
$image
protected
ImageFile|null
$image
$quality
protected
int
$quality
$retina_scale
protected
int
$retina_scale
$sizes
protected
string
$sizes
= '100vw'
$watermark
protected
bool
$watermark
Methods
cache()
Simply processes with no extra methods. Useful for triggering events.
public
cache() : $this
Return values
$thisclearAlternatives()
Clear out the alternatives.
public
clearAlternatives() : mixed
derivatives()
Generate alternative image widths, using either an array of integers, or a min width, a max width, and a step parameter to fill out the necessary widths. Existing image alternatives won't be overwritten.
public
derivatives(int|array<string|int, int> $min_width[, int $max_width = 2500 ][, int $step = 200 ]) : $this
Parameters
- $min_width : int|array<string|int, int>
- $max_width : int = 2500
- $step : int = 200
Return values
$thisfilter()
Filter image by using user defined filter parameters.
public
filter([string $filter = 'image.filters.default' ]) : $this
Parameters
- $filter : string = 'image.filters.default'
-
Filter to be used.
Return values
$thisformat()
Sets image output format.
public
format(string $format) : $this
Parameters
- $format : string
Return values
$thisgetImagePrettyName()
public
getImagePrettyName() : string
Return values
stringheight()
Allows to set the height attribute from Markdown or Twig Examples:     {{ page.media['myimg.png'].width().height().html }} {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }}
public
height([string|int $value = 'auto' ]) : $this
Parameters
- $value : string|int = 'auto'
-
A value or 'auto' or empty to use the height of the image
Return values
$thishigherQualityAlternative()
Return the image higher quality version
public
higherQualityAlternative() : ImageMediaInterface|$this
Return values
ImageMediaInterface|$this —the alternative version with higher quality
quality()
Sets or gets the quality of the image
public
quality([int|null $quality = null ]) : int|$this
Parameters
- $quality : int|null = null
-
0-100 quality
Return values
int|$thissetImagePrettyName()
Allows the ability to override the image's pretty name stored in cache
public
setImagePrettyName(string $name) : mixed
Parameters
- $name : string
sizes()
Set or get sizes parameter for srcset media action
public
sizes([string|null $sizes = null ]) : string
Parameters
- $sizes : string|null = null
Return values
stringwidth()
Allows to set the width attribute from Markdown or Twig Examples:     {{ page.media['myimg.png'].width().height().html }} {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }}
public
width([string|int $value = 'auto' ]) : $this
Parameters
- $value : string|int = 'auto'
-
A value or 'auto' or empty to use the width of the image
Return values
$thisimage()
Gets medium image, resets image manipulation operations.
protected
image() : $this
Return values
$thissaveImage()
Save the image with cache.
protected
saveImage() : string