MediaHelper

Media helper class

since

3.2

package

Application

Methods

canUpload

Checks if the file can be uploaded

canUpload(array file, string component = 'com_media', string allowedExecutables = array()) : bool
since

3.2

Arguments

file

arrayFile information

component

stringThe option name for the component storing the parameters

allowedExecutables

stringArray of executable file types that shall be whitelisted

Response

bool

checkFileExtension

Checks the file extension

checkFileExtension(string extension, string component = 'com_media', mixed allowedExecutables = array()) : bool
static
since

4.0.0

Arguments

extension

stringThe extension to be checked

component

stringThe optional name for the component storing the parameters

allowedExecutables

mixed

Response

booltrue if it passes the checks else false

checkMimeType

Checks the Mime type

checkMimeType(string mime, string component = 'com_media') : bool
since

3.7

Arguments

mime

stringThe mime to be checked

component

stringThe optional name for the component storing the parameters

Response

booltrue if mime type checking is disabled or it passes the checks else false

countFiles

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

countFiles(string dir) : array
since

3.2

Arguments

dir

stringDirectory name

Response

arrayThe number of media files and directories in the given directory

getCleanMediaFieldValue

Helper method get clean data for value stores in a Media form field by removing adapter information from the value if available (in this case, the value will have this format: images/headers/blue-flower.jpg#joomlaImage://local-images/headers/blue-flower.jpg?width=700&height=180)

getCleanMediaFieldValue(string value) : string
static
since

4.0.0

Arguments

value

string

Response

string

getMimeType

Get the Mime type

getMimeType(string file, bool isImage = false) : mixed
static
since

3.7.2

Arguments

file

stringThe link to the file to be checked

isImage

boolTrue if the passed file is an image else false

Response

mixedthe mime type detected false on error

getTypeIcon

Gets the file extension for purposed of using an icon

getTypeIcon(string fileName) : string
static
since

3.2

Arguments

fileName

stringThe filename

Response

stringFile extension to determine icon

imageResize

Calculate the size of a resized image

imageResize(int width, int height, int target) : array
static
since

3.2

Arguments

width

intImage width

height

intImage height

target

intTarget size

Response

arrayThe new width and height

isImage

Checks if the file is an image

isImage(string fileName) : bool
static
since

3.2

Arguments

fileName

stringThe filename

Response

bool

isValidLocalDirectory

Method to check if the given directory is a directory configured in FileSystem - Local plugin

isValidLocalDirectory(string directory) : bool
static
since

4.0.0

Arguments

directory

string

Response

bool

toBytes

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

toBytes(string|int val) : int
since

3.3

Arguments

val

string|intThe value to be converted to bytes.

Response

intThe calculated bytes value from the input.

Constants

EXECUTABLES

A special list of blocked executable extensions, skipping executables that are typically executable in the webserver context as those are fetched from Joomla\CMS\Filter\InputFilter

Value array('js', 'exe', 'dll', 'go', 'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta', 'ins', 'isp', 'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb', 'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh', 'html', 'htm', 'msi')
since

4.0.0

Type(s)

string[]