• Resolved Omarchh

    (@omarchh)


    Hello, I wonder if there is any function that puts the title on image, I have used pods_image to display it but only adds the “alt” attribute not the “title” attribute on the image.

    I would like to know if I’m doing something wrong or your plugin doesn’t have that functionality.

    I have this code:

    $url_img_pro = get_post_meta( $post->ID, 'imagen', true );
    $img_pro = pods_image($url_img_pro, 'full');

    https://ww.wp.xz.cn/plugins/pods/

Viewing 1 replies (of 1 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    pods_image is just a ‘wrapper’ function for the wp_get_attachment_image function; I’ve actually noticed not including the title seems to be ‘intended’ (see the codex):

    https://developer.ww.wp.xz.cn/reference/functions/wp_get_attachment_image/

    By default it will grab the ‘alt’, then the ‘caption’ and finally the post_title if nothing has been set. I had to confirm myself by checking using that function against our function and the ‘title’ is left out by default.

    If you want to include it, you can pass it as an array to the 4th item in your pods_image call (see the parameters $attributes) from our docs page on pods_image:
    http://pods.io/docs/code/field-functions/pods-image/

    Take a look at this code sample from Stefanxo; I was trying to figure out how to blend it with your code above, but since you’re not actually opening a pods object above, I can’t throw a display() in there against the id of the image, but you can pull the post_title using WordPress methods to snag it from the $url_img_pro (which should include the Image attachment ID).

Viewing 1 replies (of 1 total)

The topic ‘Title on images’ is closed to new replies.