Skip to content

Instantly share code, notes, and snippets.

@jasperf
Last active October 21, 2021 00:05
Show Gist options
  • Save jasperf/7a2203e8f575f298991e5be121ffc436 to your computer and use it in GitHub Desktop.
Save jasperf/7a2203e8f575f298991e5be121ffc436 to your computer and use it in GitHub Desktop.
Advanced Custom Field to load an image by attachment
$banner_img = get_field('banner_image', 'option');
$size = 'full'; // (thumbnail, medium, large, full or custom size)
echo wp_get_attachment_image( $banner_img, $size, '', ["class" => "banner-image"] );
echo '<a href="" class="wp-block-button__link outline" style="position:absolute; top:76%; right:3%;">hide</a>';
window.onload = function() {
var el = document.getElementById('banner');
el.addEventListener("click",function() {
this.style.display = "none";
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment