I am trying to: Display an image field from custom post type using alt text entered in the media library. The image shortcode implies that using alt="%%ALT%%" will put the alt text into the result HTML. This is not the case, nor does it even add alt="". This is an issue for accessibility reasons.
I cannot simply use the post title as the alt text because it is not accurate for the purposes of alt text, nor will the same alt text work for multiple images on the same page. I also cannot add any additional code to the functions.php file.
Link to a page where the issue can be seen: enlace oculto
I expected to see: Image html with an alt attribute
Instead, I got: Image html without alt attribute
Hi there,
Thank you for contacting us and I'll be happy to assist.
I've tested the Type's image field shortcode ( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/#image ) on my test website and it generated the "alt" attribute as expected.
Shortcode used:
[types field="employee-image" alt="%%ALT%%" title="%%TITLE%%" size="thumbnail"][/types]
Backend screenshot:
enlace oculto
Frontend screenshot:
enlace oculto
Please check if the shortcode was used with alt attribute and the actual image includes the alt text in its media library field.
In case the issue still persists, please test the shortcode again with only Toolset plugins enabled and a default WordPress theme (like Twenty Seventeen), to rule out any code conflict.
I hope this helps and let me know how it goes.
regards,
Waqar
I activated the Twenty Seventeen theme and deactivated other plugins (aside from the multisite must-use plugins). The alt attributes still do not show up: enlace oculto
Here is the template code:
[wpv-post-title]<br><br>
[types field='photo' title='%%TITLE%%' alt='%%ALT%%' size='thumbnail' resize='proportional'][/types]<br><br>
[types field='testing-more-photos' title='%%TITLE%%' alt='%%ALT%%' size='medium' resize='proportional' separator=', '][/types]
I've attached photos of the alt text in the media library.
Hi there,
Thank you for waiting and for sharing further details.
While I'm still not able to reproduce this behavior of the missing "alt" attribute, I found a similar report, where the same issue was resulted due to incorrect/incomplete site migration from one URL to another.
( https://toolset.com/forums/topic/alt-tag-not-displaying/#post-594618 )
To confirm if your website has the same issue, please upload a new image that hasn't been uploaded to the media library before and then use it with your image field. If it shows the "alt" tag correctly, you'll need to update your website's database to use the correct "guid" values, for the existing image uploads.
regards,
Waqar
Hi, I've been out for a few days, but I'll look into this more and report back. Thanks!
Thank you and I'll wait for an update.
regards,
Waqar