Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-04-12 07:32:06

joanlafulla_Almas
Member
Registered: 2011-02-25
Posts: 21

Automatic Alt text for my images

I need to establish a rule to automatically introduce alt text in the main image of my article. Something like this:

<txp:image alt=“This is a still of the movie <txp:title />, directed by <txp:custom_field name=‘director’ /> in <txp:custom_field name=‘año’ />” />

I think this is NOT possible with <txp: image /> default tag.

Do you know of any plugin or solution to cover this need?

Offline

#2 2024-04-12 08:11:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

Re: Automatic Alt text for my images

No, but you can wire it up by hand. Something like this (untested) :

<if::article_image>
<txp:images limit="1">
<img src="<image::url />" alt="This is a still of the movie <txp:title />, directed by <custom::field name='director' /> in <custom::field name='año' />" />
</txp:images>
</if::article_image>

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2024-04-12 08:39:19

joanlafulla_Almas
Member
Registered: 2011-02-25
Posts: 21

Re: Automatic Alt text for my images

Thank you very much. It works perfectly :-)

Offline

#4 2024-04-13 13:52:01

etc
Developer
Registered: 2010-11-11
Posts: 5,210
Website GitHub

Re: Automatic Alt text for my images

For the record, in txp 4.9-dev <txp:image /> seems to take alt attribute.

Offline

Board footer

Powered by FluxBB