Skip to content

Instantly share code, notes, and snippets.

@chekle
Created July 16, 2023 22:37
Show Gist options
  • Save chekle/56895de79bfea13474208fb0b3d4e91b to your computer and use it in GitHub Desktop.
Save chekle/56895de79bfea13474208fb0b3d4e91b to your computer and use it in GitHub Desktop.
Background Images - Examples Using CSS & ACF
style="background-image:url('<?php $image = get_sub_field('image'); $size = 'full'; if( $image ) { echo wp_get_attachment_image_url( $image, $size ); } ?>');"
style="background-image: linear-gradient(269.77deg, rgba(0, 0, 0, 0.2) 2.1%, rgba(0, 0, 0, 0.6) 100%), url(<?php $image = get_sub_field('background_image'); $size = 'full'; if( $image ) { echo wp_get_attachment_image_url( $image, $size ); } ?>);"
/* Background Images CSS */
background-image:url(images/image.jpg);
background-repeat: no-repeat;
background-size:cover;
background-position:center;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment