Back to MediaHelper class

Method checkMimeType

private bool
checkMimeType
(mixed $mime, mixed $component = 'com_media')
Checks the Mime type
Parameters
  • string $mime The mime to be checked
  • string $component The optional name for the component storing the parameters
Returns
  • bool true if mime type checking is disabled or it passes the checks else false
Since
  • 3.7
Class: MediaHelper
Project: Joomla

Method checkMimeType - Source code

/**
 * Checks the Mime type
 *
 * @param   string  $mime       The mime to be checked
 * @param   string  $component  The optional name for the component storing the parameters
 *
 * @return  boolean  true if mime type checking is disabled or it passes the checks else false
 *
 * @since   3.7
 */
private function checkMimeType($mime, $component = 'com_media') : bool
{
    $params = ComponentHelper::getParams($component);
    if ($params->get('check_mime', 1)) {
        $allowedMime = $params->get('upload_mime', 'image/jpeg,image/gif,image/png,image/bmp,image/webp,application/msword,application/excel,' . 'application/pdf,application/powerpoint,text/plain,application/x-zip');
        // Get the mime type configuration
        $allowedMime = array_map('trim', explode(',', $allowedMime));
        // Mime should be available and in the allowed list
        return !empty($mime) && \in_array($mime, $allowedMime);
    }
    // We don't check mime at all or it passes the checks
    return true;
}