Skip to content

Instantly share code, notes, and snippets.

@joeyz
Created October 9, 2014 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeyz/90aad3ce2c85586a1ea5 to your computer and use it in GitHub Desktop.
Save joeyz/90aad3ce2c85586a1ea5 to your computer and use it in GitHub Desktop.
Replace Image sizes for mobile instead of squishing them using ACF repeater field
<?php if( have_rows('home_slider_images', options) ): ?>
<div id="maximage">
<?php while( have_rows('home_slider_images', options) ): the_row();
// vars
$image = get_sub_field('slide_image');
$imageTablet = get_sub_field('tablet_image');
//Check and see if were NOT at a mobile screen size
if(!wp_is_mobile()) :
?>
//Serve the normal size
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
<?php else: ?>
//Serve the smaller image
<img src="<?php echo $imageTablet['url']; ?>" alt="<?php echo $image['alt'] ?>" />
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment