Back to top

Affiliate Link: Looking to Monetize With Ads?? We Personally Use:

Ezoic

Add Title Display To Images On Hover

Featured Tiles
As an Amazon Associate we earn from qualifying purchases made on our website. If you make a purchase through links from this website, we may get a small share of the sale from Amazon and other similar affiliate programs. You can read our complete legal information for more details.

This will require the code snippets plugin to allow you to add the code which will append on the title attribute to your images when added to a post. This will allow the Title of the image to display to the viewer who hovers the mouse over the image on your site.

function acabado_add_img_title( $attr, $attachment = null ) {
    $img_title = trim( strip_tags( $attachment->post_title ) );
    $attr['title'] = $img_title;
    return $attr;
}
add_filter( 'wp_get_attachment_image_attributes','acabado_add_img_title', 10, 2 );

Many had asked why the ALT tag doesn’t display on hover, this is actually intended functionality as the ALT tag is to describe the image to visually impaired and non-loading images to give context to what is missing.

The TITLE tag can display if it is added to a theme to display, in Acabado this isn’t added to the theme so the display doesn’t work, the code snippet above will enable this display which will give you that text area to use on any media upload.

If you find a post helpful and feel like rewarding my effort with the price of a beer, please donate here

About Josh Koop

Hey Everyone! I hope that the short article you read today has taken you from a place of frustration to a place of excited anticipation for your visitors! Please let me know of anything you need for Acabado that can help you achieve your goals!

My Posts | Website

Josh Koop

Hey Everyone! I hope that the short article you read today has taken you from a place of frustration to a place of excited anticipation for your visitors! Please let me know of anything you need for Acabado that can help you achieve your goals!

Leave a Reply

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

Recent Content