Thread Starter
LS
(@lsterling03)
Alternatively, if you don’t want to modify the <li> — you could add a universal class to the <a> tag like <a class="menu-image"> so that no matter whether the title is above, below, before, or after, the <a> will have a consistent class designating it as an image link. Right now, the link only has a class specific to the location of the title like “menu-image-title-below”.
I know I can also add my own class to the <li> using the WordPress menu class field, but it would be great if your plugin added it automatically so I didn’t have to remind my users to add it manually.
Thanks!
Hi, thnx for feedback.
Menu links already has classes, try to use default twenty-whatever theme, also see the source code https://github.com/zviryatko/menu-image/blob/master/menu-image.php#L260-L318
Thread Starter
LS
(@lsterling03)
I switched to the TwentySixteen theme and the problem is the same. There is not a class on the <li>. I’m looking for a general class like “has-image” to be added to the <li>. There are classes on the <a> tags, but those are specific classes that relate to the position of the title. I think it would be good to have a general/overall class so that you can apply styles to any image link, regardless of position.
Thread Starter
LS
(@lsterling03)
I edited your plugin (menu-image.php) to accomplish 2 things:
1. Only apply the menu-image classes IF the item has an image.
2. Add a general class that is not dependent on the position.
So I changed ~line 280 from this:
$class = "menu-image-title-{$position}";
To this:
if ($item->thumbnail_id ) {
$class = "has-menu-image menu-image-title-{$position}";
}
I think these are helpful additions to the plugin, so perhaps you will consider adding them to a future release.