Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ACF Get Image snippets
<?php // Get Image url (for background) ?>
<?php $bgImage = esc_html(get_field('img_field')); ?>
<?php $bgURL = wp_get_attachment_image_src($bgImage, 'full'); ?>
<div class="bg" style="background-image: url(<?php echo $bgURL[0]; ?>);"></div>
<?php // Get Image attatchment (for full image output) ?>
<?php $bpImage = esc_html(get_field('img_field')); ?>
<?php echo wp_get_attachment_image($bpImage, 'full'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.