Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-12-19 21:18:12

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

How to get alt text for an image?

How do I get just the alternate text for the image ID for that article, (just the text, not the image)?

Sorry if this is obvious and I’m just missing it somehow…

EDIT: The reason I need this is because I want to add a title tag that uses the alt text, so that the text comes up as a tooltip when a user rolls over the image.

Last edited by frickinmuck (2021-12-19 21:23:19)


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

#2 2021-12-19 21:31:59

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

Re: How to get alt text for an image?

The txp:image_info tag is your friend here.

Something like this will fetch just the alt tag for the assigned article image, if it’s used:

<if::article_image>
<txp:images><txp:image_info type="alt" /></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 2021-12-19 22:58:13

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

Re: How to get alt text for an image?

My hero, as always. Thanks so much.


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

Board footer

Powered by FluxBB