Documentation

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: ![Example](myimg.png?width=200&height=400) ![Example](myimg.png?resize=100,200&width=100&height=200) ![Example](myimg.png?width=auto&height=auto) ![Example](myimg.png?width&height) {{ 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: ![Example](myimg.png?width=200&height=400) ![Example](myimg.png?resize=100,200&width=100&height=200) ![Example](myimg.png?width=auto&height=auto) ![Example](myimg.png?width&height) {{ 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]]

Methods

cache()

Simply processes with no extra methods. Useful for triggering events.

public cache() : $this
Return values
$this

clearAlternatives()

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
$this

filter()

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
$this

format()

Sets image output format.

public format(string $format) : $this
Parameters
$format : string
Return values
$this

getImagePrettyName()

public getImagePrettyName() : string
Return values
string

height()

Allows to set the height attribute from Markdown or Twig Examples: ![Example](myimg.png?width=200&height=400) ![Example](myimg.png?resize=100,200&width=100&height=200) ![Example](myimg.png?width=auto&height=auto) ![Example](myimg.png?width&height) {{ 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
$this

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|$this

setImagePrettyName()

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
string

width()

Allows to set the width attribute from Markdown or Twig Examples: ![Example](myimg.png?width=200&height=400) ![Example](myimg.png?resize=100,200&width=100&height=200) ![Example](myimg.png?width=auto&height=auto) ![Example](myimg.png?width&height) {{ 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
$this

image()

Gets medium image, resets image manipulation operations.

protected image() : $this
Return values
$this

saveImage()

Save the image with cache.

protected saveImage() : string
Return values
string

        
On this page

Search results