Documentation

MediaObjectTrait

Class Medium

Table of Contents

Properties

$mime  : string
$_thumbnail  : MediaObjectInterface|null
$alternatives  : array<string|int, MediaObjectInterface>
$attributes  : array<string|int, mixed>
$medium_querystring  : array<string|int, mixed>
$metadata  : array<string|int, mixed>
$mode  : string
$styleAttributes  : array<string|int, mixed>
$thumbnailType  : string|null
$thumbnailTypes  : array<string|int, mixed>
$timestamp  : string

Methods

__call()  : $this
Allow any action to be called on this medium from twig or markdown
__toString()  : string
Return string representation of the object (html).
addAlternative()  : mixed
Add alternative Medium to this Medium.
addMetaFile()  : mixed
Add meta file for the medium.
attribute()  : $this
Add custom attribute to medium.
classes()  : $this
Add a class to the element from Markdown or Twig Example: ![Example](myimg.png?classes=float-left) or ![Example](myimg.png?classes=myclass1,myclass2)
copy()  : static
Create a copy of this media object
display()  : MediaObjectInterface|null
Switch display mode.
get()  : mixed
Get value by using dot notation for nested arrays/objects.
getAlternatives()  : array<string|int, mixed>
id()  : $this
Add an id to the element from Markdown or Twig Example: ![Example](myimg.png?id=primary-img)
lightbox()  : MediaLinkInterface
Turn the current Medium into a Link with lightbox enabled
link()  : MediaLinkInterface
Turn the current Medium into a Link
meta()  : Data
Return just metadata from the Medium object
metadata()  : array<string|int, mixed>
Returns an array containing just the metadata
parsedownElement()  : array<string|int, mixed>
Get an element (is array) that can be rendered by the Parsedown engine
querystring()  : string
Get/set querystring for the file's url
reset()  : $this
Reset medium.
set()  : $this
Set value by using dot notation for nested arrays/objects.
setTimestamp()  : $this
Set querystring to file modification timestamp (or value provided as a parameter).
style()  : $this
Allows to add an inline style attribute from Markdown or Twig Example: ![Example](myimg.png?style=float:left)
thumbnail()  : $this
Switch thumbnail.
thumbnailExists()  : bool
Helper method to determine if this media item has a thumbnail or not
url()  : string
Return URL to file.
urlHash()  : string
Get/set hash for the file's url
urlQuerystring()  : string
Get the URL with full querystring
createLink()  : MediaLinkInterface
createThumbnail()  : mixed
getItems()  : array<string|int, mixed>
getThumbnail()  : ThumbnailImageMedium|null
Get the thumbnail Medium object
sourceParsedownElement()  : array<string|int, mixed>
Parsedown element for source display mode
textParsedownElement()  : array<string|int, mixed>
Parsedown element for text display mode

Properties

$medium_querystring

protected array<string|int, mixed> $medium_querystring = []

$styleAttributes

protected array<string|int, mixed> $styleAttributes = []

$thumbnailTypes

protected array<string|int, mixed> $thumbnailTypes = ['page', 'default']

Methods

__call()

Allow any action to be called on this medium from twig or markdown

public __call(string $method, array<string|int, mixed> $args) : $this
Parameters
$method : string
$args : array<string|int, mixed>
Attributes
#[ReturnTypeWillChange]
Return values
$this

__toString()

Return string representation of the object (html).

public abstract __toString() : string
Attributes
#[ReturnTypeWillChange]
Return values
string

addMetaFile()

Add meta file for the medium.

public abstract addMetaFile(string $filepath) : mixed
Parameters
$filepath : string

attribute()

Add custom attribute to medium.

public attribute([string $attribute = null ][, string $value = '' ]) : $this
Parameters
$attribute : string = null
$value : string = ''
Return values
$this

classes()

Add a class to the element from Markdown or Twig Example: ![Example](myimg.png?classes=float-left) or ![Example](myimg.png?classes=myclass1,myclass2)

public classes() : $this
Return values
$this

copy()

Create a copy of this media object

public copy() : static
Return values
static

get()

Get value by using dot notation for nested arrays/objects.

public abstract get(string $name[, mixed $default = null ][, string|null $separator = null ]) : mixed
Parameters
$name : string

Dot separated path to the requested value.

$default : mixed = null

Default value (or null).

$separator : string|null = null

Separator, defaults to '.'

Tags
example

$value = $this->get('this.is.my.nested.variable');

Return values
mixed

Value.

getAlternatives()

public getAlternatives([bool $withDerived = true ]) : array<string|int, mixed>
Parameters
$withDerived : bool = true
Return values
array<string|int, mixed>

id()

Add an id to the element from Markdown or Twig Example: ![Example](myimg.png?id=primary-img)

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

lightbox()

Turn the current Medium into a Link with lightbox enabled

public lightbox([int|null $width = null ][, int|null $height = null ][, bool $reset = true ]) : MediaLinkInterface
Parameters
$width : int|null = null
$height : int|null = null
$reset : bool = true
Return values
MediaLinkInterface

Turn the current Medium into a Link

public link([bool $reset = true ][, array<string|int, mixed> $attributes = [] ]) : MediaLinkInterface
Parameters
$reset : bool = true
$attributes : array<string|int, mixed> = []
Return values
MediaLinkInterface

metadata()

Returns an array containing just the metadata

public metadata() : array<string|int, mixed>
Return values
array<string|int, mixed>

parsedownElement()

Get an element (is array) that can be rendered by the Parsedown engine

public parsedownElement([string|null $title = null ][, string|null $alt = null ][, string|null $class = null ][, string|null $id = null ][, bool $reset = true ]) : array<string|int, mixed>
Parameters
$title : string|null = null
$alt : string|null = null
$class : string|null = null
$id : string|null = null
$reset : bool = true
Return values
array<string|int, mixed>

querystring()

Get/set querystring for the file's url

public querystring([string|null $querystring = null ][, bool $withQuestionmark = true ]) : string
Parameters
$querystring : string|null = null
$withQuestionmark : bool = true
Return values
string

set()

Set value by using dot notation for nested arrays/objects.

public abstract set(string $name, mixed $value[, string|null $separator = null ]) : $this
Parameters
$name : string

Dot separated path to the requested value.

$value : mixed

New value.

$separator : string|null = null

Separator, defaults to '.'

Tags
example

$data->set('this.is.my.nested.variable', $value);

Return values
$this

setTimestamp()

Set querystring to file modification timestamp (or value provided as a parameter).

public setTimestamp([string|int|null $timestamp = null ]) : $this
Parameters
$timestamp : string|int|null = null
Return values
$this

style()

Allows to add an inline style attribute from Markdown or Twig Example: ![Example](myimg.png?style=float:left)

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

thumbnail()

Switch thumbnail.

public thumbnail([string $type = 'auto' ]) : $this
Parameters
$type : string = 'auto'
Return values
$this

thumbnailExists()

Helper method to determine if this media item has a thumbnail or not

public thumbnailExists([string $type = 'page' ]) : bool
Parameters
$type : string = 'page'

;

Return values
bool

url()

Return URL to file.

public abstract url([bool $reset = true ]) : string
Parameters
$reset : bool = true
Return values
string

urlHash()

Get/set hash for the file's url

public urlHash([string|null $hash = null ][, bool $withHash = true ]) : string
Parameters
$hash : string|null = null
$withHash : bool = true
Return values
string

urlQuerystring()

Get the URL with full querystring

public urlQuerystring(string $url) : string
Parameters
$url : string
Return values
string

createThumbnail()

protected abstract createThumbnail(string $thumb) : mixed
Parameters
$thumb : string

getItems()

protected abstract getItems() : array<string|int, mixed>
Return values
array<string|int, mixed>

sourceParsedownElement()

Parsedown element for source display mode

protected sourceParsedownElement(array<string|int, mixed> $attributes[, bool $reset = true ]) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>
$reset : bool = true
Return values
array<string|int, mixed>

textParsedownElement()

Parsedown element for text display mode

protected textParsedownElement(array<string|int, mixed> $attributes[, bool $reset = true ]) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>
$reset : bool = true
Return values
array<string|int, mixed>

        
On this page

Search results