Documentation

MediaFileInterface extends MediaObjectInterface

Class implements media file interface.

Table of Contents

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.
exists()  : bool
Check if this medium exists or not
get()  : mixed
Get value by using dot notation for nested arrays/objects.
getAlternatives()  : array<string|int, mixed>
Get list of image alternatives. Includes the current media image as well.
getMeta()  : array<string|int, mixed>
Returns an array containing the file metadata
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
modified()  : int|null
Get file modification time for the medium.
parsedownElement()  : array<string|int, mixed>
Get an element (is array) that can be rendered by the Parsedown engine
path()  : string
Return the path to file.
querystring()  : string
Get/set querystring for the file's url
relativePath()  : mixed
Return the relative path to file
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).
size()  : int
Get size of the medium.
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

Methods

__call()

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

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

__toString()

Return string representation of the object (html).

public __toString() : string
Return values
string

addMetaFile()

Add meta file for the medium.

public 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

exists()

Check if this medium exists or not

public exists() : bool
Return values
bool

get()

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

public 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()

Get list of image alternatives. Includes the current media image as well.

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

If true, include generated images as well. If false, only return existing files.

Return values
array<string|int, mixed>

getMeta()

Returns an array containing the file metadata

public getMeta() : array<string|int, mixed>
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 $width = null ][, int $height = null ][, bool $reset = true ]) : MediaLinkInterface
Parameters
$width : int = null
$height : int = null
$reset : bool = true
Return values
MediaLinkInterface

metadata()

Returns an array containing just the metadata

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

modified()

Get file modification time for the medium.

public modified() : int|null
Return values
int|null

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>

path()

Return the path to file.

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

path to file

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

relativePath()

Return the relative path to file

public relativePath([bool $reset = true ]) : mixed
Parameters
$reset : bool = true

set()

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

public 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 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

        
On this page

Search results