Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
My favicon.ico has some large images in it as well as the typical 16 by 16px version of the website icon. When I use the admin_menu without the toolbar it doesn't resize correctly, i.e. It shows the larger icons. To fix the "bug" I simply changed the width=16 height=16 in the php to be style="width:16px; height:16px".
Like so:
diff --git a/docroot/sites/all/modules/contrib/admin_menu/admin_menu.inc b/docroot/sites/all/modules/contrib/admin_menu/admin_menu.inc
index e212970..7181589 100644
--- a/docroot/sites/all/modules/contrib/admin_menu/admin_menu.inc
+++ b/docroot/sites/all/modules/contrib/admin_menu/admin_menu.inc
@@ -1028,6 +1028,6 @@ function template_preprocess_admin_menu_icon(&$variables) {
* @ingroup themeable
*/
function theme_admin_menu_icon($variables) {
- return '<img class="admin-menu-icon" src="' . $variables['src'] . '" width="16" height="16" alt="' . $variables['alt'] . '" />';
+ return '<img class="admin-menu-icon" src="' . $variables['src'] . '" style="width:16px; height:16px" alt="' . $variables['alt'] . '" />';
}
or more succinctly:
function theme_admin_menu_icon($variables) {
from this:
- return '<img class="admin-menu-icon" src="' . $variables['src'] . '" width="16" height="16" alt="' . $variables['alt'] . '" />';
to this:
+ return '<img class="admin-menu-icon" src="' . $variables['src'] . '" style="width:16px; height:16px" alt="' . $variables['alt'] . '" />';
}
Hopefully helpful to someone.
D
Comment | File | Size | Author |
---|---|---|---|
#4 | 2166143.admin_menu.favicon-size.patch | 313 bytes | joachim |
admin_fix.jpg | 73.59 KB | dshumaker |
Comments
Comment #1
tompagabor CreditAttribution: tompagabor commentedThe width and height HTML attirbutes already resize images. I tested it with a 32x32px size icon. Maybe your custom style override something?
The screenshot:
https://www.evernote.com/shard/s229/sh/eec20fb1-399c-4ed9-a1f2-6dbd360cf...
Comment #2
MarcoR CreditAttribution: MarcoR commentedThe problem seems to appear when using a Zen sub theme, even it doesn't contain any custom CSS. The file normalize.css seems to be taken too serious by some browsers (Safari).
Adding this to a custom CSS file solves the problem:
Even though this problem comes not from admin_menu, maybe it is too specific to be handled in the general theme and should be corrected here.
Comment #3
joachim CreditAttribution: joachim commentedI'm seeing this problem on a site theme where the favicon is 32x32, and the site theme has a reset rule that sets all images to 100% width.
Comment #4
joachim CreditAttribution: joachim commentedComment #5
garbo CreditAttribution: garbo commentedThis is a silly but annoying bug that can easily be fixed with either one of the above suggestions. I would like it very much to be fixed to save me from some unnecessary frustration.
Comment #6
joachim CreditAttribution: joachim commentedIf my patch fixes the problem for you, could you set the issue to RTBC please? That will hopefully get it some attention from a maintainer.
Comment #7
garbo CreditAttribution: garbo commentedComment #8
truls1502Could someone here help me to provide me with more information? Because I am not able to reproduce it, so is it related to a particular theme or a general theme?
I have tested with, but still no luck:
Comment #9
dshumaker CreditAttribution: dshumaker commentedFour years ago when reported it, I did indeed use the Zen sub theme as @MarcoR mentioned. Did you @truls1502 try it with that theme? About three years ago I stopped using the Zen sub theme and around the same (although can't be exact) time I stopped seeing the bug.
Comment #10
truls1502Ok, so it seems it is theme' issues, and I am going to close this one. So if you or anyone is still facing the issue, please to re-open the issue, provide with more information and a screenshot that might help us to troubleshoot it. :)