class MediaHelper

Media helper class

Methods

boolean
isImage( string $fileName)

Checks if the file is an image

static  string
getTypeIcon( string $fileName)

Gets the file extension for purposed of using an icon

boolean
canUpload( array $file, string $component = 'com_media')

Checks if the file can be uploaded

static  array
imageResize( integer $width, integer $height, integer $target)

Calculate the size of a resized image

array
countFiles( string $dir)

Counts the files and directories in a directory that are not php or html files.

integer
toBytes( string|integer $val)

Small helper function that properly converts any configuration options to their byte representation.

Details

boolean isImage( string $fileName)

Checks if the file is an image

Parameters

string $fileName The filename

Return Value

boolean

static string getTypeIcon( string $fileName)

Gets the file extension for purposed of using an icon

Parameters

string $fileName The filename

Return Value

string File extension to determine icon

boolean canUpload( array $file, string $component = 'com_media')

Checks if the file can be uploaded

Parameters

array $file File information
string $component The option name for the component storing the parameters

Return Value

boolean

static array imageResize( integer $width, integer $height, integer $target)

Calculate the size of a resized image

Parameters

integer $width Image width
integer $height Image height
integer $target Target size

Return Value

array The new width and height

array countFiles( string $dir)

Counts the files and directories in a directory that are not php or html files.

Parameters

string $dir Directory name

Return Value

array The number of media files and directories in the given directory

integer toBytes( string|integer $val)

Small helper function that properly converts any configuration options to their byte representation.

Parameters

string|integer $val The value to be converted to bytes.

Return Value

integer The calculated bytes value from the input.