Archived topic
Media Attachment Size for Header Element Background Image
3 replies · Started by Jesse on May 24, 2020
Can the Media Attachment Size set in Customiser be applied to the Background Image of Header Elements instead of always pulling in the full image size?
Hi there,
interesting idea - not an option at the moment but you can use this PHP snippet to change it:
add_filter( 'generate_page_hero_background_image_url', function( $image_url, $options ) {
if ( is_singular() && has_post_thumbnail() ) {
$image_url = get_the_post_thumbnail_url( get_the_ID(), 'large' );
}
return $image_url;
}, 10, 2 );
Awesome! That helps with performance a bit :) Using an image shortcode may have been better, but this is great where a background image is used.
I realised that having this as an option may cause issues with the parallax setting if the chosen size isn't big enough.
Thanks!
You're welcome