function _favicon_get_favicon_file in Favicon 7
Get the full path and mime to the favicon.
Return value
array|bool FALSE if invalid file is set. Array with keys: 'path' string full system path to file. 'mime' string file mime type.
3 calls to _favicon_get_favicon_file()
- FaviconTestCase::assertFavicon in ./
favicon.test - Assert that the favicon is as expected
- FaviconTestCase::testFailForBadMimeType in ./
favicon.test - Check that nothing is returned if an invalid shortcut icon is specified.
- favicon_shortcut_icon in ./
favicon.module - Menu callback; forwards to the favicon.
File
- ./
favicon.module, line 54 - Module file for favicon module.
Code
function _favicon_get_favicon_file() {
drupal_theme_initialize();
$favicon = theme_get_setting('favicon_path');
// If no theme favicon is supplied, use the Drupal default.
$favicon = empty($favicon) ? 'misc' . DIRECTORY_SEPARATOR . 'favicon.ico' : $favicon;
if (!empty($favicon) && $favicon[0] != DIRECTORY_SEPARATOR) {
$favicon = DIRECTORY_SEPARATOR . $favicon;
}
$file_path = getcwd() . $favicon;
if (!file_exists($file_path)) {
return FALSE;
}
$mime = file_get_mimetype($file_path);
$allowed_favicon_types = array(
'image/x-icon',
'image/vnd.microsoft.icon',
);
if (!in_array($mime, $allowed_favicon_types)) {
watchdog('favicon', 'Invalid mime type @mime for favicon at @path', array(
'@type' => $mime,
'@path' => $file_path,
), WATCHDOG_ERROR);
return FALSE;
}
return array(
'path' => $file_path,
'mime' => $mime,
);
}