Documentation

MediaLibraryItem
in package

Represents a file or folder in the Media Library.

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

FILE_TYPE_AUDIO  = 'audio'
FILE_TYPE_DOCUMENT  = 'document'
FILE_TYPE_IMAGE  = 'image'
FILE_TYPE_VIDEO  = 'video'
TYPE_FILE  = 'file'
TYPE_FOLDER  = 'folder'
$lastModified  : int
$path  : string
$publicUrl  : string
$size  : int
$type  : string
$audioExtensions  : array<string|int, mixed>
$imageExtensions  : array<string|int, mixed>
$videoExtensions  : array<string|int, mixed>
__construct()  : mixed
getFileType()  : string
Returns the file type by its name.
isFile()  : bool
lastModifiedAsString()  : string
Returns the item last modification date as string.
sizeToString()  : string
Returns the item size as string.

Constants

Properties

$lastModified

public int $lastModified

Contains the last modification time (Unix timestamp).

$path

public string $path

Specifies the item path relative to the Library root.

$publicUrl

public string $publicUrl

Specifies the public URL of the item.

$size

public int $size

Specifies the item size. For files the item size is measured in bytes. For folders it contains the number of files in the folder.

$audioExtensions

protected static array<string|int, mixed> $audioExtensions

Contains a default list of audio files and directories to ignore. Override with config: cms.storage.media.audioExtensions

$imageExtensions

protected static array<string|int, mixed> $imageExtensions

Contains a default list of image files and directories to ignore. Override with config: cms.storage.media.imageExtensions

$videoExtensions

protected static array<string|int, mixed> $videoExtensions

Contains a default list of video files and directories to ignore. Override with config: cms.storage.media.videoExtensions

Methods

__construct()

public __construct(string $path, int $size, int $lastModified, string $type, string $publicUrl) : mixed
Parameters
$path : string
$size : int
$lastModified : int
$type : string
$publicUrl : string
Return values
mixed

getFileType()

Returns the file type by its name.

public getFileType() : string

The known file types are: image, video, audio, document

Return values
string

Returns the file type or NULL if the item is a folder.

lastModifiedAsString()

Returns the item last modification date as string.

public lastModifiedAsString() : string
Return values
string

Returns the item's last modification date as string.

sizeToString()

Returns the item size as string.

public sizeToString() : string

For file-type items the size is the number of bytes. For folder-type items the size is the number of items contained by the item.

Return values
string

Returns the size as string.

Search results