You are here

public static function DrupalFavicon::validateFile in Favicon 7.2

Validates a file to be used for a favicon.

Parameters

object $file: A favicon file object

Throws

DrupalFaviconValidationException

1 call to DrupalFavicon::validateFile()
DrupalFavicon::getFileFromUri in src/DrupalFavicon.php
Convert a URI into a file object.

File

src/DrupalFavicon.php, line 75

Class

DrupalFavicon

Code

public static function validateFile($file) {
  if (!in_array($file->filemime, array(
    'image/vnd.microsoft.icon',
    'image/x-icon',
    'image/png',
    'image/gif',
    'image/jpeg',
  ), TRUE)) {
    throw new DrupalFaviconValidationException("The file {$file->uri} has an invalid MIME type of <em>{$file->filemime}</em> for use as a shortcut icon.");
  }
}