MediaLibraryItem

Represents a file or folder in the Media Library.

 class System\Classes\MediaLibraryItem

Constants

Constant Description
FILE_TYPE_AUDIO
string "audio"
FILE_TYPE_DOCUMENT
string "document"
FILE_TYPE_IMAGE
string "image"
FILE_TYPE_VIDEO
string "video"
TYPE_FILE
string "file"
TYPE_FOLDER
string "folder"

Properties

public $lastModified : int

Contains the last modification time (Unix timestamp).

public $path : string

Specifies the item path relative to the Library root.

public $publicUrl : string

Specifies the public URL of the item.

public $size : int

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

public $type : string

Specifies the item type.

protected static $audioExtensions : array

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

protected static $imageExtensions : array

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

protected static $videoExtensions : array

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

Methods

public __construct (string $path, int $size, int $lastModified, string $type, string $publicUrl)

Parameters
Property Description
$path
string
$size
int
$lastModified
int
$type
string
$publicUrl
string
Returns
mixed

public getFileType () : string

Returns the file type by its name.

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

Returns
string

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

public isFile () : bool

Returns
bool

public lastModifiedAsString () : string

Returns the item last modification date as string.

Returns
string

Returns the item's last modification date as string.

public sizeToString () : string

Returns the item size as 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.

Returns
string

Returns the size as string.

Extended by

Class Description
MediaLibraryItem

Represents a file or folder in the Media Library.

Copyright © 2024 Winter CMS