Skip to content

Instantly share code, notes, and snippets.

@solid-pixel
Created March 21, 2017 13:06
Show Gist options
  • Save solid-pixel/62166342d85db3d6469c7e0b1adf9386 to your computer and use it in GitHub Desktop.
Save solid-pixel/62166342d85db3d6469c7e0b1adf9386 to your computer and use it in GitHub Desktop.
Set ACF image (ID) as Background
<?php
$imgID = get_field('field_slug');
$imgSize = "large"; // (thumbnail, medium, large, full or custom size)
$imgArr = wp_get_attachment_image_src( $imgID, $imgSize );
// $url = $image[0];
// width = $image[1];
// height = $image[2];
?>
<div id="post-splash" style="background-image: url(<?php echo $imgArr[0]; ?> );">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment