I do believe that, while Responsive favicons is a great module, Metatag module itself should include a "shortcut icon" tag as this is part of drupal core. This patch adds support for overriding the favicon in the advanced section of the metatag configuration.
By default it will use the path defined in the appearance/theme configuration.
#8 You are right about that (and I should probably not have been coding on a Friday night). I propose the following solution:
A new controller "DrupalShortcutIconMetaTag" with an extra form element "type" which allows the user to enter the mime type of the shortcut icon. It will still use "metatag_link_rel" theme function to render the element, but with an extra attribute "type".
Alternatively we could just determine the mime type of the file by calling the "file_get_mimetype" function. However, I prefer the end user to make this decision as there is some discussion regarding which mime type to use for the .ico files (i.e. IANA standard image/vnd.microsoft.icon or image/x-icon)
I tidied it up a little bit and extended the existing theme function rather than adding another one; I'm not entirely convinced it shouldn't be a separate theme function yet, I'll ponder on it.
Does this mean, that once an update with this fix comes out, there won't be any need anymore to use the favicon module (https://www.drupal.org/project/favicon)?
Edit: I've probably misinterpreted it. For me it was about avoiding all 404 errors when some browsers try to access the favicon at /favicon.ico and ignore the "shortcut icon" tag, which is already correctly set based on the theme settings.
Comments
Comment #1
dave reidRelated project: https://www.drupal.org/project/responsive_favicons
Comment #2
etroid commentedI do believe that, while Responsive favicons is a great module, Metatag module itself should include a "shortcut icon" tag as this is part of drupal core. This patch adds support for overriding the favicon in the advanced section of the metatag configuration.
By default it will use the path defined in the appearance/theme configuration.
Comment #4
etroid commentedUploaded the wrong patch in the previous post by mistake...
Comment #5
etroid commentedComment #7
etroid commentedUpdated the metatag.test file to include the 'shortcut icon'.
Comment #8
damienmckennaIf the site builder customizes the shortcut icon, isn't it possible that the mimetype would change from what is defined in the theme?
Comment #9
etroid commented#8 You are right about that (and I should probably not have been coding on a Friday night). I propose the following solution:
A new controller "DrupalShortcutIconMetaTag" with an extra form element "type" which allows the user to enter the mime type of the shortcut icon. It will still use "metatag_link_rel" theme function to render the element, but with an extra attribute "type".
Alternatively we could just determine the mime type of the file by calling the "file_get_mimetype" function. However, I prefer the end user to make this decision as there is some discussion regarding which mime type to use for the .ico files (i.e. IANA standard image/vnd.microsoft.icon or image/x-icon)
Comment #10
damienmckennaThe nested trinary operators need to be redone, they gets ugly really fast.
Comment #11
damienmckennaStandardized the issue title.
Comment #12
damienmckennaI think this should be added to #2085747: Add new meta tags: touch icons once it is finished.
Comment #13
jcnventuraDoes it still?
Comment #14
damienmckennaThis needs to be updated to use the new metatag_favicons module.
Comment #15
jcnventuraOne question, about all these favicons... Can't we generate all sizes automatically?
Comment #16
damienmckennaTheoretically, but Metatag would need a file uploader and then provide a bunch of image styles, one for each size.
Comment #17
etroid commentedI've refactored the patch to make use of the new metatag_favicons sub module.
Comment #18
etroid commentedComment #20
damienmckennaI tidied it up a little bit and extended the existing theme function rather than adding another one; I'm not entirely convinced it shouldn't be a separate theme function yet, I'll ponder on it.
Comment #21
damienmckennaI changed it back to having a custom theme function, instead of overloading the existing favicons theme function.
Comment #22
damienmckennaTested, and this version will actually pull the default value from the theme settings.
Comment #23
damienmckennaCommitted.
Comment #26
tr-drupal commentedDoes this mean, that once an update with this fix comes out, there won't be any need anymore to use the favicon module (https://www.drupal.org/project/favicon)?Edit: I've probably misinterpreted it. For me it was about avoiding all 404 errors when some browsers try to access the favicon at /favicon.ico and ignore the "shortcut icon" tag, which is already correctly set based on the theme settings.