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; ?>
    		<?php endif; ?>