Skip Navigation

[Résolu] PDF thumbnails – how to add ALT tags?

Ce fil est résolu. Voici une description du problème et la solution proposée.


How to include the current post's title as the alt text to images, added through a custom shortcode.


Suggested to use "wpv-post-title" shortcode, to get the current post's title.

Relevant Documentation:

This support ticket is created Il y a 3 années. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Marqué : ,

This topic contains 2 réponses, has 2 voix.

Last updated by Alan Il y a 3 années.

Assigned support staff: Waqar.



I have followed this article to create the function that allows me to use the PDF thumbnail in a View, via a shortcode:

This can be seen on my test site:
hidden link

Each thumbnail image is included within the view by this shortcode:

[getpublicationpdfimg size='medium']

For accessibility reasons, I would like to add the ALT tag to each image, simply using the post title or file name as the alt tag (the PDF file name will be the same as the Post Title in my case, so either could be used.)

Can you please provide a way to achieve this?

Many thanks



Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alan,

Thank you for waiting.

To use the current post's title as the "alt" text in the image's thumbnail, you can use the "[wpv-post-title]" shortcode:

So, that your code line will change from:

return '<img src=' .$image_src  . ' class="pubdoc-pdf-image"> ';


$post_title = do_shortcode('[wpv-post-title]');

return '<img src=' .$image_src  . ' class="pubdoc-pdf-image" alt="'.$post_title.'"> ';

I hope this helps and please let me know if you need any further assistance around this.



My issue is resolved now. Thank you!