MediaHelper
Media helper class
since |
3.2 |
---|---|
package |
Joomla CMS |
Methods
canUpload
Checks if the file can be uploaded
canUpload(mixed||string|int file, component = 'com_media', string||string|int allowedExecutables = []) :
since |
3.2 |
---|
Arguments
- file
array<string|int, mixed>
File information- component
string
The option name for the component storing the parameters- allowedExecutables
array<string|int, string>
Array of executable file types that shall be whitelisted
Response
bool
checkFileExtension
Checks the file extension
checkFileExtension( extension, component = 'com_media', allowedExecutables = []) :
since |
4.0.0 |
---|
Arguments
- extension
string
The extension to be checked- component
string
The optional name for the component storing the parameters- allowedExecutables
mixed
Response
bool
true if it passes the checks else false
checkMimeType
Checks the Mime type
checkMimeType( mime, component = 'com_media') :
since |
3.7 |
---|
Arguments
- mime
string
The mime to be checked- component
string
The optional name for the component storing the parameters
Response
bool
true 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( dir) : mixed||string|int
since |
3.2 |
---|
Arguments
- dir
string
Directory name
Response
array<string|int, mixed>
The 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( value) :
since |
4.0.0 |
---|
Arguments
- value
string
Response
string
getMimeType
Get the Mime type
getMimeType( file, isImage = false) :
since |
3.7.2 |
---|
Arguments
- file
string
The link to the file to be checked- isImage
bool
True if the passed file is an image else false
Response
mixed
the mime type detected false on error
getTypeIcon
Gets the file extension for purposed of using an icon
getTypeIcon( fileName) :
since |
3.2 |
---|
Arguments
- fileName
string
The filename
Response
string
File extension to determine icon
imageResize
Calculate the size of a resized image
imageResize( width, height, target) : mixed||string|int
since |
3.2 |
---|
Arguments
- width
int
Image width- height
int
Image height- target
int
Target size
Response
array<string|int, mixed>
The new width and height
isImage
Checks if the file is an image
isImage( fileName) :
since |
3.2 |
---|
Arguments
- fileName
string
The filename
Response
bool
isValidLocalDirectory
Method to check if the given directory is a directory configured in FileSystem - Local plugin
isValidLocalDirectory( directory) :
since |
4.0.0 |
---|
Arguments
- directory
string
Response
bool
isValidSvg
Check if a file is a valid SVG
isValidSvg( file, shouldLogErrors = true) :
since |
4.3.0 |
---|
Arguments
- file
string
- shouldLogErrors
bool
Response
bool
toBytes
Small helper function that properly converts any configuration options to their byte representation.
toBytes(string|int val) :
since |
3.3 |
---|
Arguments
- val
string|int
The value to be converted to bytes.
Response
int
The 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 | ['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)
array<string|int, string>