Title: Displaying titles
Last modified: August 22, 2016

---

# Displaying titles

 *  Resolved [trixee](https://wordpress.org/support/users/trixee/)
 * (@trixee)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/)
 * Love this plug-in but there are a couple of things I would like to do if possible:
 * 1. On hover, I would like to display the image title.
    2. When the menu changes
   to responsive mode, I would like to revert to text only rather than using the
   images.
 * Any ideas on how I can achieve these?
 * Many thanks,
    Trish
 * [https://wordpress.org/plugins/menu-image/](https://wordpress.org/plugins/menu-image/)

Viewing 14 replies - 1 through 14 (of 14 total)

 *  [zviryatko](https://wordpress.org/support/users/zviryatko/)
 * (@zviryatko)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503046)
 * Copy `menu_image_nav_menu_item_filter` function from plugin to your theme, add
   it filter `walker_nav_menu_start_el` like in plugin, and replace line 280 to 
   something like
    `$item_output .= '<span class="visible-in-small-resolution">'.
   $link . '</span>' . $image;` and in style.css hide element `.visible-in-small-
   resolution` for all except low resolution media query.
 *  Thread Starter [trixee](https://wordpress.org/support/users/trixee/)
 * (@trixee)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503048)
 * Hi author, many thanks for your help. I’m not sure I’m understanding correctly:
 * 1. Do I copy menu_image_nav_menu_item_filter function to the functions.php file
   in the theme?
 * 2. Where do I find walker_nav_menu_start_el?
 * 3. I can’t find that element in my style.css.
 * Thanks for your time…
 *  [zviryatko](https://wordpress.org/support/users/zviryatko/)
 * (@zviryatko)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503064)
 * 1 – yes,
    2 – [https://github.com/zviryatko/menu-image/blob/master/menu-image.php#L63](https://github.com/zviryatko/menu-image/blob/master/menu-image.php#L63)
   3 – in copied code change this line [https://github.com/zviryatko/menu-image/blob/master/menu-image.php#L280](https://github.com/zviryatko/menu-image/blob/master/menu-image.php#L280)
   to what i wrote in previous comment.
 *  Thread Starter [trixee](https://wordpress.org/support/users/trixee/)
 * (@trixee)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503119)
 * Many thanks! Will try this on Monday 🙂
 *  [zviryatko](https://wordpress.org/support/users/zviryatko/)
 * (@zviryatko)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503120)
 * Why not today?)
 *  Thread Starter [trixee](https://wordpress.org/support/users/trixee/)
 * (@trixee)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503121)
 * It’s the weekend man! 🙂
 *  [zviryatko](https://wordpress.org/support/users/zviryatko/)
 * (@zviryatko)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503123)
 * I thought today is friday..
    don’t be afraid, just try it, i can help)
 *  Thread Starter [trixee](https://wordpress.org/support/users/trixee/)
 * (@trixee)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503125)
 * It’s Friday, but night time where I am so I’m already on my second glass of wine
   😉 I’m on the wrong computer as well at the moment and can’t remote in.
 *  [zviryatko](https://wordpress.org/support/users/zviryatko/)
 * (@zviryatko)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503127)
 * oh, ok, you convinced me 😉
 *  Thread Starter [trixee](https://wordpress.org/support/users/trixee/)
 * (@trixee)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503241)
 * Hi zviryatko,
 * OK so I’ve tried the above, but it doesn’t appear to be working. I’ve probably
   missed something somewhere.
    I can’t find the element .visible-in-small-resolution
   in my style.css or anything similar.
 * This is the function I’ve ended up with in my functions.php”
 *     ```
       function menu_image_nav_menu_item_filter( $item_output, $item, $depth, $args ) {
       		$attributes = !empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) . '"' : '';
       		$attributes .= !empty( $item->target ) ? ' target="' . esc_attr( $item->target ) . '"' : '';
       		$attributes .= !empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) . '"' : '';
       		$attributes .= !empty( $item->url ) ? ' href="' . esc_attr( $item->url ) . '"' : '';
       		//added below line to display menu title on hover
       		add_filter( 'walker_nav_menu_start_el', array( $this, 'menu_image_nav_menu_item_filter' ), 10, 4 );
       		$image_size = $item->image_size ? $item->image_size : apply_filters( 'menu_image_default_size', 'menu-36x36' );
       		$position   = $item->title_position ? $item->title_position : apply_filters( 'menu_image_default_title_position', 'after' );
       		$class      = "menu-image-title-{$position}";
       		$this->setUsedAttachments($image_size, $item->thumbnail_id);
       		if ( $item->thumbnail_hover_id ) {
       			$this->setUsedAttachments($image_size, $item->thumbnail_hover_id);
       			$hover_image_src = wp_get_attachment_image_src( $item->thumbnail_hover_id, $image_size );
       			$margin_size = $hover_image_src[1];
       			$image = "<span class='menu-image-hover-wrapper'>";
       			$image .= wp_get_attachment_image( $item->thumbnail_id, $image_size, false, "class=menu-image {$class}" );
       			$image .= wp_get_attachment_image( $item->thumbnail_hover_id, $image_size, false, array(
       				'class' => "hovered-image {$class}",
       				'style' => "margin-left: -{$margin_size}px;",
       			));
       			$image .= '</span>';;
       			$class .= ' menu-image-hovered';
       		} else {
       			$image = wp_get_attachment_image( $item->thumbnail_id, $image_size, false, "class=menu-image {$class}" );
       			$class .= ' menu-image-not-hovered';
       		}
   
       		$item_output = "{$args->before}<a{$attributes} class='{$class}'>";
       		$link        = $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
       		switch ( $position ) {
       			case 'hide':
       				//$item_output .= $image; //replace with line below to display menu title on hover
       				$item_output .= '<span class="visible-in-small-resolution">' . $link . '</span>' . $image;
       				break;
       			case 'before':
       				$item_output .= $link . $image;
       				break;
       			case 'after':
       			default:
       				$item_output .= $image . $link;
       				break;
       		}
       		$item_output .= "</a>{$args->after}";
   
       		return $item_output;
       	}
       ```
   
 * Thanks again for your time.
 *  [zviryatko](https://wordpress.org/support/users/zviryatko/)
 * (@zviryatko)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503257)
 * Hi, maybe you forgot about `add_filter`?
    `add_filter( 'walker_nav_menu_start_el','
   menu_image_nav_menu_item_filter', 11, 4 );`
 *  Thread Starter [trixee](https://wordpress.org/support/users/trixee/)
 * (@trixee)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503287)
 * Ended up getting this to work via CSS:
 *     ```
       #prime_nav li a span:last-child {
       	display:none;
       }
       #prime_nav li:hover a span:last-child,
       #prime_nav li.current-menu-item a span:last-child
       {
       	display:block;
       }
       ```
   
 * 🙂
 *  [zviryatko](https://wordpress.org/support/users/zviryatko/)
 * (@zviryatko)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503288)
 * Hi, yes, it what you need 🙂
 *  Thread Starter [trixee](https://wordpress.org/support/users/trixee/)
 * (@trixee)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503296)
 * Thanks.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Displaying titles’ is closed to new replies.

 * ![](https://ps.w.org/menu-image/assets/icon-128x128.png?rev=2123398)
 * [Menu Image, Icons made easy](https://wordpress.org/plugins/menu-image/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/menu-image/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/menu-image/)
 * [Active Topics](https://wordpress.org/support/plugin/menu-image/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/menu-image/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/menu-image/reviews/)

 * 14 replies
 * 2 participants
 * Last reply from: [trixee](https://wordpress.org/support/users/trixee/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/displaying-titles/#post-5503296)
 * Status: resolved