Adding dynamic Media Library Alt Text to Featured Image elements in builder

Hello!

I am pulling the ‘featured_image_id’ into my Single Post Layout page via the Image element and want to apply the Media Library alt text to the element for accessibility purposes. I have searched the forum and noticed there are a number of old posts regarding this topic but as it’s been a few years since, I’m wondering if its possible that there is a new solution or update to provide this functionality?

What I have tried already:

In reviewing the forum posts, most have directed users to this thread: Featured Image Alt Text in Dynamic Content - however, I have tried to implement this solution and it doesn’t work for me, the Alt text remains as “Image” (after clearing caches).

Thank you in advance!

Hello @be3designs,

Thanks for writing to us.

I have tested the given code on my end, and it worked fine. Please note that the code provided in the mentioned thread serves as a guide only and is to help you get started. Implementing it and maintaining the code will be out of our support scope. For further maintenance for new possible versions of the theme that may cause the customization to break, you will need to hire a developer or subscribe to One, where customization questions are answered.

To investigate it further, please copy your live site to a staging server so we can troubleshoot freely without breaking your live site. Please remember that we can’t guarantee any fixes.
And give us access to the secure note, including:

  • WordPress Site URL & Login URL
  • WordPress Admin username/password
  • FTP login details
  • Exact page URL

To create a secure note, click the key icon underneath any of your posts.

Thanks for understanding

I’ve added a secure note to my first post, thanks so much for your prompt response!

I completely understand the scope, I was hoping there was a built-in function for this feature or change at this time, but thanks again for taking a quick look.

Hello @be3designs,

Thanks for sharing the login details. It seems that the code is working fine on your server. There was no alt text on the post featured image, which you have set to the post, just because the dynamic content code was displaying "Image " in place of the alt text. Please have a look at the screen recording, and please check your site. Please change the alt text as per your image, since I have added a demo alt text(“Hello World”) at the moment to your post featured image for testing purposes.

Thanks

Oh. My. Goodness. Well, internet, this is embarrassing, but I would use the one placeholder graphic for this purpose that I didn’t set an Alt tag for. :man_facepalming:

Thanks so much for catching that, @prakash_s and showing me the silly step I missed!

Are there still plans to have this feature integrated into the framework?

Hello @be3designs,

We have added a Twig framework to our builder, which can be used for such a feature. Please have a look at this doc to learn more about how to use Twig in the builder and access the post featured image meta value.

Hope it helps
Thanks

Thanks so much, I will check out the documentation and start getting twiggy with it :grin:

Hello @be3designs,

Glad that we were able to help you.

Thanks