Home › Forums › Front-end Issues › WordPress 4.4 responsive images › Reply To: WordPress 4.4 responsive images
I have used wp_get_attachment_image_src to display my images – I’m doing it this way as I need to use the image’s caption (post_excerpt) as my ‘alt’ content. Frustratingly (for me with limited experience!) timstl code works only when using wp_get_attachment_image. With this in mind how would I change timstl’s snippet so it works form me also? Here’s what I’m working with…
<?php if(get_field('post_images')): ?>
<?php while(the_repeater_field('post_images')): ?>
<?php $image = wp_get_attachment_image_src(get_sub_field('post_image'), 'large');
$largeImage = wp_get_attachment_image_src(get_sub_field('post_image'), 'full');
$attachment_id = get_post_thumbnail_id($post_id); ?>
<li <?php the_sub_field('module_class');?>>
<a href="<?php echo $largeImage[0]; ?>" title="<?php $attachment = get_post($attachment_id); echo($attachment->post_excerpt); ?>">
<img src="<?php echo $image[0]; ?>" alt="<?php $attachment = get_post($attachment_id); echo($attachment->post_excerpt); ?>" /></a></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
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.