summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-04 07:04:21 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-04 07:04:21 +0000
commit24057c3d53a22373e0b575a36f49ab8e965b6934 (patch)
tree75793c721b5e81352355ee52ad5b7d43939500c9
parent3fa324a1b5a6a7360216a88201f10b000915f574 (diff)
downloadbrdo-24057c3d53a22373e0b575a36f49ab8e965b6934.tar.gz
brdo-24057c3d53a22373e0b575a36f49ab8e965b6934.tar.bz2
#531476 by aaron and mfb: Add favicon mimetype as a theme setting to avoid expensive calls to file system.
-rw-r--r--includes/theme.inc8
-rw-r--r--includes/theme.maintenance.inc6
-rw-r--r--modules/system/system.admin.inc7
3 files changed, 11 insertions, 10 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 15795e68b..562655e90 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1041,6 +1041,8 @@ function theme_get_settings($key = NULL) {
'logo_path' => '',
'default_favicon' => 1,
'favicon_path' => '',
+ // Use the IANA-registered MIME type for ICO files as default.
+ 'favicon_mimetype' => 'image/vnd.microsoft.icon',
'main_menu' => 1,
'secondary_menu' => 1,
'toggle_logo' => 1,
@@ -1888,11 +1890,7 @@ function template_preprocess_page(&$variables) {
// Add favicon.
if (theme_get_setting('toggle_favicon')) {
$favicon = theme_get_setting('favicon');
- $type = file_get_mimetype($favicon);
- // Use the genereic MIME type for favicons if no other was found.
- if ($type == 'application/octet-stream') {
- $type = 'image/x-icon';
- }
+ $type = theme_get_setting('favicon_mimetype');
drupal_add_html_head('<link rel="shortcut icon" href="' . check_url($favicon) . '" type="' . check_plain($type) . '" />');
}
diff --git a/includes/theme.maintenance.inc b/includes/theme.maintenance.inc
index 2dacf27ab..20b2f6505 100644
--- a/includes/theme.maintenance.inc
+++ b/includes/theme.maintenance.inc
@@ -216,11 +216,7 @@ function template_preprocess_maintenance_page(&$variables) {
// Add favicon
if (theme_get_setting('toggle_favicon')) {
$favicon = theme_get_setting('favicon');
- $type = file_get_mimetype($favicon);
- // Use the genereic MIME type for favicons if no other was found.
- if ($type == 'application/octet-stream') {
- $type = 'image/x-icon';
- }
+ $type = theme_get_setting('favicon_mimetype');
drupal_add_html_head('<link rel="shortcut icon" href="' . check_url($favicon) . '" type="' . check_plain($type) . '" />');
}
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index 2242c2f24..cf5335600 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -513,6 +513,13 @@ function system_theme_settings(&$form_state, $key = '') {
*/
function system_theme_settings_submit($form, &$form_state) {
$values = $form_state['values'];
+ if (empty($values['default_favicon']) && !empty($values['favicon_path'])) {
+ $mimetype = file_get_mimetype($values['favicon_path']);
+ // Use the default MIME type for favicons if no other was found.
+ if ($mimetype != 'application/octet-stream') {
+ $values['favicon_mimetype'] = $mimetype;
+ }
+ }
$key = $values['var'];
// Exclude unnecessary elements before saving.