Menu Image – WordPress plugin Free download

Click to Download

Menu Image

Description

Adds a field to load the image in a menu item and displays the image inside the link in the menu before the text.
Now you can upload the second image and set to the mouse over/out effect.
And also change position of title or hide title if need.
And… load images via media uploader!
Now WPML compliant!

Screenshots

Admin screen
Menu preview in standard twenty-thirteen theme

Installation

Upload menu-image to the /wp-content/plugins/ directory
Activate the plugin through the ‘Plugins’ menu in WordPress
Go to /wp-admin/nav-menus.php
Edit exist menu item or add new menu item and just upload image than click Save Menu
See your menu on site
(WMPL users only) Goto WPML > WP Menus Sync and click to Sync

FAQ

How to add custom attributes to menu item link (useful for integration with dropdown menus)

Use core nav_menu_link_attributes and nav_menu_item_title filters.

How to wrap menu link text in `span` html element

Menu link text is already wrapped in span.menu-image-title.

How to add another size for the image?

To add a new size (or remove an old one) add a function to the menu_image_default_sizes filter. For example

<?php
add_filter( 'menu_image_default_sizes', function($sizes) {

  // remove the default 36x36 size
  unset($sizes['menu-36x36']);

  // add a new size
  $sizes['menu-50x50'] = array(50,50);

  // return $sizes (required)
  return $sizes;

});
?>

How to make hovered image visible on current page of menu item?

Add this link to style.css

.menu-item.current-menu-item > a.menu-image-hovered img.hovered-image {
  opacity: 1;
}

If you have problem with srcset image problem on WordPress version >= 4.4 and Azure hosting

If you srcset property look like this:

Then you can disable srcset (add it to your function.php):

/**
 * Fix for broken images on azure & wordpress 4.4
 * @see https://wordpress.org/support/topic/wordpress-adding-absolute-paths
 */
add_filter( 'wp_calculate_image_srcset', '__return_false' );

Reviews

Leave a Reply

Your email address will not be published. Required fields are marked *