Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #187102

    hwressnigg
    Participant

    Hi,

    How do I display title and alt text metadata for featured images on mouseover?

    #187386

    Paul R
    Moderator

    Hi,

    Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL as stated on the forum entrance page. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #189354

    hwressnigg
    Participant

    Hi, my URL is: http://www.dave-dewitt.com/

    The issue I’m writing in about seems to be a WordPress issue, where the meta title information for featured images is technically there but does not appear on mouse-over unlike non-featured images which do show title meta on mouse-over. Can you provide a code solution for this?

    #189959

    Zeshan
    Member

    Hi there,

    Upon checking, the title of images showing just fine for me on mouse hover (see: http://prntscr.com/5w1a9m). Would you mind confirming again or point us to the specific image where you want to show the title on mouse hover?

    Thanks!

    #190256

    hwressnigg
    Participant

    Thanks for the reply. I’d like the title of a featured image to show on mouseover inside of a post/portfolio item. For instance when I mouseover the featured image in this post: http://www.dave-dewitt.com/2015/01/18/im-a-novelist-too/ nothing appears even though title meta data exists. Compare this to non-featured images I have in the body of my posts which do show title metadata on mouseover and you’ll see what I mean. Is this a theme X default or WordPress issue? In any case, it doesn’t make sense that a featured image wouldn’t show this data on mouseover as every other image on my site does.

    #190865

    Rad
    Moderator

    Hi there,

    Meta titles that appears when hovered are only applicable for image with links. Your inserted image is from library in which you chosen not to have a link. The meta title will be added along with the link when inserted, and you can modify those meta titles through that link when viewed on text mode.

    Thanks!

    #191448

    hwressnigg
    Participant

    Thanks for the reply, but your response doesn’t make sense. You can’t set a link for a featured image in WordPress. See screenshot with greyed-out non-editable URL field: https://www.dropbox.com/s/gmfk6017xdb25w7/Screen%20Shot%202015-01-25%20at%2010.14.48%20PM.png?dl=0

    #191909

    Zeshan
    Member

    Hi there,

    We’re sorry for the confusion!

    This is the default behaviour that the link of featured image will be disabled on single post page. However, if you wish to add the link in single post page too, you can add following code in your child theme’s functions.php file:

    if ( ! function_exists( 'x_featured_image' ) ) :
      function x_featured_image( $cropped = '' ) {
    
        $stack     = x_get_stack();
        $fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;
    
        if ( has_post_thumbnail() ) {
    
          if ( $cropped == 'cropped' ) {
            if ( $fullwidth ) {
              $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
            } else {
              $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
            }
          } else {
            if ( $fullwidth ) {
              $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
            } else {
              $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
            }
          }
    
          switch ( is_singular() ) {
            case true:
              printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
                esc_url( get_permalink() ),
                esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
                $thumb
              );
              break;
            case false:
              printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
                esc_url( get_permalink() ),
                esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
                $thumb
              );
              break;
          }
    
        }
    
      }
    endif;
    

    Hope this helps. 🙂

    Thank you.

    #192137

    hwressnigg
    Participant

    Hi again,

    Actually, all I want to do is add the title meta data to a featured image. Is there a way to add title meta data (which will appear on mouseover) to a featured image within a post without also making it a link?

    #192538

    Christopher
    Moderator

    Hi there,

    Please change your code to :

    if ( ! function_exists( 'x_featured_image' ) ) :
      function x_featured_image( $cropped = '' ) {
    
        $stack     = x_get_stack();
        $fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;
    
        if ( has_post_thumbnail() ) {
    
          if ( $cropped == 'cropped' ) {
            if ( $fullwidth ) {
              $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
            } else {
              $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
            }
          } else {
            if ( $fullwidth ) {
              $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
            } else {
              $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
            }
          }
    
          switch ( is_singular() ) {
            case true:
              printf( '<a  class="entry-thumb" title="%2$s">%3$s</a>',
                esc_url( get_permalink() ),
                esc_attr( sprintf( __( '"%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
                $thumb
              );
              break;
            case false:
              printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
                esc_url( get_permalink() ),
                esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
                $thumb
              );
              break;
          }
    
        }
    
      }
    endif;

    Hope it helps.