[Resolved] Media Attachment Size for Header Element Background Image

Home Forums Support [Resolved] Media Attachment Size for Header Element Background Image

Home Forums Support Media Attachment Size for Header Element Background Image

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1300019
    Jesse

    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?

    #1300206
    David
    Staff
    Customer Support

    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 );
    #1301403
    Jesse

    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!

    #1301643
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.