How to fetch text from "alt. text" in images
-
Hi!
I’m trying to fetch the text from what is written in the alternate text field of an image.
What I try to achive with it is this: I have an image gallery on my page, when I click the images it opens them up in a lightbox. But instead, I will link each image to a post I have written about them. So I thought I could enter url to each post in the images alternate text field, and then have the code where the link is made get that text. This way I can enter a different url for each image.
But I am a coding noob and I need help.
Here is the code I try to alter:
foreach($all_photo_arr as $photo) { $full_image_url = wp_get_attachment_image_src( $photo->ID, 'full' ); $small_image_url = wp_get_attachment_image_src( $photo->ID, 'large' ); echo '<img>'; echo '<src>'.$small_image_url[0].'</src>'; echo '<link>'.$full_image_url[0].'</link>'; echo '<title></title>'; echo '<caption></caption>'; echo '</img>'; }
I guess that the string to the “alternate text” field has to be put in somehow in between the <link> tags.
What do I put in between there to make it work? =)
- The topic ‘How to fetch text from "alt. text" in images’ is closed to new replies.