CoolCMS API

AssetVariant
in package

FinalYes

Info about one asset variant: name, public url (for `<img src>`), absolute disk path (for {@see exists()}) and real dimensions (from `meta`). A non-Doctrine value object built by {@see \App\Core\Base\Shared\System\Models\Entities\Asset}.

exists() checks the current state on disk via is_file(), not the presence of dimensions in meta (that is only a snapshot from upload/backfill and may be stale).

Table of Contents

Properties

$absolutePath  : string|null
$height  : int|null
$name  : string
$url  : string
$width  : int|null

Methods

__construct()  : mixed
exists()  : bool
Whether the variant file physically exists on disk (current state). Dimensions in `meta` would not reflect deleted or missing files.
getAbsolutePath()  : string|null
Absolute path of the variant file on disk (`null` = could not be derived).
getDimensions()  : array{width: int, height: int}|null
getHeight()  : int|null
getName()  : string
getUrl()  : string
Public (relative) path of the variant for `<img src>`.
getWidth()  : int|null

Properties

$absolutePath read-only

private string|null $absolutePath = null

Methods

__construct()

public __construct(string $name[, string $url = '' ][, string|null $absolutePath = null ][, int|null $width = null ][, int|null $height = null ]) : mixed
Parameters
$name : string
$url : string = ''
$absolutePath : string|null = null
$width : int|null = null
$height : int|null = null

exists()

Whether the variant file physically exists on disk (current state). Dimensions in `meta` would not reflect deleted or missing files.

public exists() : bool
Return values
bool

getAbsolutePath()

Absolute path of the variant file on disk (`null` = could not be derived).

public getAbsolutePath() : string|null
Return values
string|null

getDimensions()

public getDimensions() : array{width: int, height: int}|null
Return values
array{width: int, height: int}|null

getHeight()

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

getName()

public getName() : string
Return values
string

getUrl()

Public (relative) path of the variant for `<img src>`.

public getUrl() : string
Return values
string

getWidth()

public getWidth() : int|null
Return values
int|null
On this page

Search results