Beta 2: feature dynamic alt text on image in layout builder

I mentioned this in another post among a whole lot of things but thought it best to have its own post.

Now that we have a layout builder, and given you guys don’t pull the alt text from the media library, we need a way to be able to dynamically create the alt text.

At the moment the alt text only allows us to type something into the text field.

If we have built something for a product or custom post type we wouldn’t want the image to have the same alt text on every page.

1 Like

Thanks for pointing this out. I definitely see your point. At a minimum, I will make sure we add dynamic content to that input.

Getting things to a place where we can pull from the WordPress media library and just use the supplied alt text there is a priority, so it might be that we need to bite the bullet and build it for this update. Can’t confirm this at the moment, but we will be considering it.

2 Likes

I would be happy with the dynamic content option.

Option 2 would be better but happy to wait on that.

So at this point we’re leaning towards handling images by their ID, and automatically populating the Alt Text from what is stored in the WordPress media library. Will keep you updated here as that progresses.

2 Likes

Update: Really happy to say we’ve updated how images are stored in the builders and it will now save the attachment ID by default instead of the URL. This also means alt text will be automatically populated from the media library. You can still set custom alt text by using the text input (which now supports DC).

4 Likes

Awesome. Thanks.

I presume from what you are saying that this would be backwards compatible.

With the old way I catch some of my team being lazy and not updating the alt tags in the media library as they didn’t pull through. I’m constantly on them about that but I’m sure they aren’t the only ones :slight_smile:

Yes! Fully backwards compatible. It still supports direct URLs stored as the image which is how it works if you do “Insert from URL”.

Hey @alexander,

A bit of an old thread here but…

Just noticed that this feature is not working when adding BG images with alt text, it is not pulling the alt text from the media library.

Hi @Maratopia_Digital,

If you use the <img/> tag background type it should grab the alt text from the media library unless you explicitly set some text.

Could anyone explain me how this should work with Woo Product images?
I see no way to do this with the built in functions.

This would work the same irrespective of which part of the builder you are using or which layout you are using. Maybe better would be to let us know what problems you are experiencing.

1 Like

Well, I’m actually using the template that is offered to me when creating a WooCommerce store archive layout from theme.co.
By default the product title is used as alt text. But I want to use the alt text that is assigned in the media attachment in WordPress media manager.

1 Like

If you leave the alt text blank it’ll default to the Attachment alt text for those WC layouts. It looks like archive purposely setups different Alt texts, but it might be more clear to do the same as the Product image element which is has no alt text setup