How can we help?

If you are looking for support for our PokaTheme, this is the place!

Home Forums PokaTheme support How to add img title attribute on review logo?

  • This topic has 3 replies, 2 voices, and was last updated 1 year ago by admin.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #17704

    Hi there,

    I would like to be able to specify a title attribute for the image tag of the featured image of a review,
    currently only the alt attribute is displayed.

    Any suggestions on how to do this?

    this code is what i sgenerated by an affiliate table shortcode:

    <div class=”review-box-thumb review-box-thumb–counter”>

    <div class=”pokageo-flag-circle”>
    <div class=”pokageo-status-icon pokageo-status-icon-allowed icon poka-bx-check”></div>
    </div>
    ALT AS SET IN MEDIA LIB

    </div>

    HOw can we have a title attribute in the img?

    thank you!

    #17768
    admin
    Keymaster

    Hi Jean-Sebastien!

    Good to hear from you again!

    We use the default

    get_the_post_thumbnail()

    function of WordPress, which, by default, doesn’t show a “title” attribute.

    But we could give you a PHP snippet to do this. Do you want to show the “title” that you specify for each image in the Media gallery in the Dashboard?

    #17824

    Hey!

    Sorry for the late reply,

    so finally I had to come with my own snippet, using the image title (from the media library) to populate the title attribute of the image,
    something like this:

    function my_function ($attr, $attachment, $size) {
    $attr[‘title’] = get_the_title($attachment->ID); // get the Title of the attachment and use it as attribute
    return $attr;
    }
    add_filter (‘wp_get_attachment_image_attributes’, ‘my_function’,10,3 );

    (of course it depends on project context)

    #17835
    admin
    Keymaster

    Hi Jean-Sebastien!

    Thanks for sharing!

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