Skip to content

Instantly share code, notes, and snippets.

@brianmaierjr
Created September 18, 2017 15:14
Show Gist options
  • Save brianmaierjr/defcc581e7e085bf79bdb82016024e35 to your computer and use it in GitHub Desktop.
Save brianmaierjr/defcc581e7e085bf79bdb82016024e35 to your computer and use it in GitHub Desktop.
Responsive Images with ACF
<?php
$image = get_field('banner_bg_image');
$medium = $image['sizes'][ 'medium' ];
$large = $image['sizes'][ 'large' ];
$full = $image[ 'url' ];
?>
<style>
@media screen and (min-width: 1024px) {
.banner--interior {
background-image: url(<?php echo $full; ?>);
}
}
@media screen and (min-width: 801px) and (max-width: 1024px) {
.banner--interior {
background-image: url(<?php echo $large; ?>);
}
}
@media screen and (max-width: 800px) {
.banner--interior {
background-image: url(<?php echo $medium; ?>);
}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment