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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tompagabor’s picture

The 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...

MarcoR’s picture

The 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).

/**
 * Embedded content and figures
 *
 * @todo Look into adding responsive embedded video.
 */
img {
  /* Remove border when inside `a` element in IE 8/9. */
  border: 0;
  /* Improve image quality when scaled in IE 7. */
  -ms-interpolation-mode: bicubic;

  /* Suppress the space beneath the baseline */
  /* vertical-align: bottom; */

  /* Responsive images */
  max-width: 100%;
  height: auto;
  /* Correct IE 8 not scaling image height when resized. */
  width: auto;
}

Adding this to a custom CSS file solves the problem:

img.admin-menu-icon {
  width: 16px;
  height: 16px;
}

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.

joachim’s picture

Title: width=16 height=16 to style="width:16px; height:16px" » set the favicon size in CSS rather than HTML attributes
Version: 7.x-3.0-rc4 » 7.x-3.x-dev

I'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.

joachim’s picture

Status: Active » Needs review
FileSize
313 bytes
garbo’s picture

This 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.

joachim’s picture

If 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.

garbo’s picture

Status: Needs review » Reviewed & tested by the community
truls1502’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Could 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:

  • Drupal 7.59
  • admin_menu 7.x-3.x-dev updated 20 July 2018 at 12:06:21 CEST
  • And put a large favicon on Bartik-theme which is the default theme after the standard installation.
dshumaker’s picture

Four 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.

truls1502’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Ok, 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. :)