Basically I have my folder set, module enabled, so I enter menu-item edit page, I check to "use menu icon" and whatever I do it is not working! When I upload a picture it is being renamed and uploaded to the set folder, but the icon is now showing up, and when I enter menu-item edit page again I see "use menu icon" unchecked... The default icon is also not working

My folder settings are: "/files/menu_icons" - the folder is created with 777 permissions, i put inside default icon and set it in settings, and when I upload custom picture it appears there as I wrote above...

Comments

acrollet’s picture

Component: Code » User interface
Category: bug » support
Priority: Major » Minor

Hi there,

I was unable to reproduce your issue. Please post exact steps to reproduce the problem, starting with a clean installation of Drupal 7. Screenshots of your configuration settings would probably also be helpful.

thanks,
Adrian

mxwitkowski’s picture

I am having the same problem as czaku. I have installed the module, can confirm that the icon configuration options can be set for a menu item and that images are being uploaded into the default directory in the public files directory. I have cleared site cache and am not able to get the icons to appear. I am running Drupal 7.12.

emilorol’s picture

Hi,

I found the CSS background-image path to be the issue:

a.menu-256, ul.links li.menu-256 a {
background-image: url(http://default/sites/default/files/styles/menu_icon/public/menu_icons/menu_icon_256.png);
padding-left: 45px;
background-repeat: no-repeat;
background-position: left;
height: 45px;
}

Thank you,
Emil

emilorol’s picture

Hi,

I found the issue the module file in line:

<?php
$image_url = file_create_url($image_path);
?>

I replace it with:

<?php
$image_url = image_style_url($image_style, $image_path);
?>

Thank you,
Emil

emilorol’s picture

Hi,

The bug is still out there and using the fix I submitted will work until you clear the cache of the site and after that the image path stop been an absolute path to something like: http://default/sites/default/files/styles/menu_icon/public/menu_icons/me...

Thank you,
Emil

emilorol’s picture

Hi,

The replacement code on #4 should be like this:

<?php
$image_url = image_style_url($image_style, $source_uri);
?>
emilorol’s picture

Hi,

After a couple more hours of code reviews and a lot of watchdogs I noticed that the problem is that when the cache is flush the $base_url in a regular drupal installation is http://default, so in my settings.php file I set my $base_url and the problem is now gone. I wonder if in the code below:

<?php
/**
 * Implements hook_flush_caches().
 */
function menu_icons_flush_caches() {
  menu_icons_css_generate();
}
?>

something can be added that will save the trouble of adding a value to $base_url in the settings file.

Thank you,
Emil

andyg5000’s picture

#6 worked for me in 7.x-3.0-beta3

sukr_s’s picture

had a the same issue, but didn't need either #4 or #6, the issue was the site's files folder was not writeable through the entire depth.

NIKS_Artreaktor’s picture

Hello everyone.
I have the same problem -
"when I enter menu-item edit page again I see "use menu icon" unchecked."

The problem is that image generating, css creating. (even without patch #6)
But always "use menu icon" unchecked and css create ONLY for ONE last edited menu item.

Like this module, but it not working///

NIKS_Artreaktor’s picture

emilorol’s picture

Hi,

In this page (http://drupal.org/node/1437184) there are a couple of patches that solve the issue with the icons not showing or been removed after the cache is cleared using Drush.

Note: there are some servers out there with bad permissions configuration that will force you to set the icons and css folders permission to 777.

acrollet’s picture

Status: Active » Closed (duplicate)

Closing as a duplicate of #743368: $GLOBAL['base_url'] set to http://default - until a fix is committed there (if that happens), one may avoid this problem by using the "-l http://site.url/" option to drush, or (better yet set up drushrc.php)

abhaysaraf’s picture

I have edited menu_icons_css_item.tpl.php and now I can see the corresponding images-
Added a variable 'global $base_url' and updated 'background-image' attribute value.
Code is now looking somewhat like:

<?php global $base_url;?>
a.menu-<?php print $mlid ?>, ul.links li.menu-<?php print $mlid ?> a {
  background-image: url(<?php echo $base_url.$path ?>);
  padding-<?php print "$pos:$size"?>px;
  background-repeat: no-repeat;
  background-position: <?php print $pos?>;
  height: <?php print $height?>px;
}
wirka’s picture

Hi, does dev version have been updated?

codemode01’s picture

Issue summary: View changes

#6 worked for me.

In menu_icons.module, at line #517...

replace - $image_url = file_create_url($image_path);
with - $image_url = image_style_url($image_style, $source_uri);

Run cron > Edit menu item > Check 'Use an icon" > Enter path without the preceeding '/' > Working now

Thanks!

morybel’s picture

#6 worked for me also,

Thank you.

antonior14’s picture

Same issue for me too.

After loading image for menu item, it appear clear in the admin table, and menu item disappear, any DOM refered to img was added

I tried too to replace code as described by codemode01

emi_bcn’s picture

Hi,
I have Drupal on a subdirectory. Only #14 worked for me.

Thanks @abhaysaraf !!

wescleyteixeira’s picture

I have Drupal on a subdirectory. Only #14 worked for me.
New uploaded images are showed only after cleaning the cache.

Thanks @abhaysaraf [2] !