Created
October 9, 2014 14:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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