Using ACF Pro plugin - How to get alt tags using repeater with Image ID?

admin2025-06-05  3

This question already has answers here: How To Retrieve An Image Attachment's Alt Text? (7 answers) Closed 6 years ago.

I have the following code for calling the images in the slider but no idea on how to get the alt tag. I tried varied methods but I could be missing something. Please help. Possibly I am missing this in calling the respective variables but no idea thereof.

foreach ( get_field('images') as $image ): ?>
<div>
<img src="<?php echo $image['image']['url']; ?>" width="90" alt="<?php echo $alt; ?>" />
</div>
<?php endforeach;

Please help.

This question already has answers here: How To Retrieve An Image Attachment's Alt Text? (7 answers) Closed 6 years ago.

I have the following code for calling the images in the slider but no idea on how to get the alt tag. I tried varied methods but I could be missing something. Please help. Possibly I am missing this in calling the respective variables but no idea thereof.

foreach ( get_field('images') as $image ): ?>
<div>
<img src="<?php echo $image['image']['url']; ?>" width="90" alt="<?php echo $alt; ?>" />
</div>
<?php endforeach;

Please help.

Share Improve this question edited Dec 12, 2018 at 11:51 Keyur Amin asked Dec 12, 2018 at 10:28 Keyur AminKeyur Amin 31 silver badge4 bronze badges 1
  • @JacobPeattie It could be but I am using the _wp_attachment_image_alt tag as well but as revised the content I am hereby quoting the same that I could be wrong in calling the alt tag in any way. And that is where I need help. – Keyur Amin Commented Dec 12, 2018 at 10:44
Add a comment  | 

1 Answer 1

Reset to default 0

I figured out the answer while doing some estimations. (and it was no where near to the suggested topics).

Change

alt="<?php echo $alt; ?>"

to

alt="<?php echo $image['image']['alt']; ?>"
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749106090a316413.html

最新回复(0)