Home › Forums › Add-ons › Repeater Field › Getting Alt Text to show up in Image Field › Reply To: Getting Alt Text to show up in Image Field
Thanks…
So I tried it both ways, but maybe I’m not understanding the second part (getting the alt text to work).
I tried
<?php get_header(); ?>
<div id="gallery-content">
<h1><?php the_title(); ?></h1>
<p><?php the_field('gallery_info'); ?></p>
<?php if(get_field('gallery_images')): ?>
<?php while(the_repeater_field('gallery_images')): ?>
<?php $image = wp_get_attachment_image_src(get_sub_field('image', false), 'gallery'); ?>
<?php $image2 = wp_get_attachment_image_src(get_sub_field('image', false), 'full'); ?>
<a href="<?php echo $image2[0]; ?>" rel="shadowbox[gallery]"><img class="gallery-images" src="<?php echo $image[0]; ?>" alt="<?php echo $image[βaltβ]; ?>β /a>
<?php endwhile; endif; ?>
And
<?php get_header(); ?>
<div id="gallery-content">
<h1><?php the_title(); ?></h1>
<p><?php the_field('gallery_info'); ?></p>
<?php if(get_field('gallery_images')): ?>
<?php while(the_repeater_field('gallery_images')): ?>
<?php $image = wp_get_attachment_image_src(get_sub_field('image', false), 'gallery'); ?>
<?php $image2 = wp_get_attachment_image_src(get_sub_field('image', false), 'full'); ?>
<a href="<?php echo $image2[0]; ?>" rel="shadowbox[gallery]"><img class="gallery-images" src="<?php echo $image[0]; ?>" $alt = get_post_meta(get_sub_field(image), '_wp_attachment_image_alt', true); ?>β /a>
<?php endwhile; endif; ?>
Both options give code links instead of images on the gallery page. Can you see something I’m doing wrong? Thanks!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.