[Resolved] Featured Image Title

Home Forums Support [Resolved] Featured Image Title

Home Forums Support Featured Image Title

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1330748
    Marin

    Hi,

    My featured image doesn’t seem to have the ‘image title’ within the blog post. All other images inserted in the blog post seem to have the image title as I can see the text when I hover over the image (most browsers display title text of the image in a yellow tool tip that appears when you hover your mouse over the element). But for my featured images, I can’t see this once the blog post is published.

    I appreciate any help with this.

    Thanks,
    Marin

    #1331117
    David
    Staff
    Customer Support

    Hi there,

    WordPress removed the title as a default attribute some time back.
    You can add it back in with this PHP Snippet:

    add_filter( 'wp_get_attachment_image_attributes', 'tl_add_img_title', 10, 2 );
    // Add title attribute to featured image
    function tl_add_img_title( $attr, $attachment = null){
    	$attr['title'] = get_post( $attachment->ID )->post_title;
    	return $attr;
    }

    https://docs.generatepress.com/article/adding-php/

    #1331901
    Marin

    Great! Thanks David.

    #1332197
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.