System\Classes\MediaLibraryItem

Source: ~/modules/system/classes/MediaLibraryItem.php

Represents a file or folder in the Media Library.

Public properties

public string $path

Specifies the item path relative to the Library root.

public integer $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.

public integer $lastModified

Contains the last modification time (Unix timestamp).

public string $type

Specifies the item type.

public string $publicUrl

Specifies the public URL of the item.

Protected properties

protected static array $imageExtensions

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

protected static array $videoExtensions

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

protected static array $audioExtensions

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

Public methods

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

public string getFileType()

Returns the file type by its name. The known file types are: image, video, audio, document

public bool isFile()

public string lastModifiedAsString()

Returns the item last modification date as string.

public string sizeToString()

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.