Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress WordPress Customizer API Custom WordPress Customizer Settings Making the Logo Uploader Work with postMessage

Ulises Calvo
Ulises Calvo
2,233 Points

Why background-blend-mode does not render in the customizer real time postMessage?

Hello, Does anyone have an idea on why background-blend-mode is not applied in postMessage (real time) when using the WordPress Customizer?

I have an image_control that looks like this

$wp_customize->add_setting(
        'parallax_image',  
            array(
                'default'               => get_stylesheet_directory_uri() . '/images/big-team.jpg'
                'transport'             => 'postMessage'
        )
        );



  $wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'parallax_image',  
             array(
                'settings'              => 'parallax_image', //cta_image_uploader
                'section'               => 'team_parallax',          // cta_section
                'label'                 => __( ‘Photo’ ),
                'description' => __( 'Upload an image of your team.',  'namastethemecustomizer' )
                        )
                )
        );

My styles are these:

function namaste_style_header() {
<style type ="text/css">
<?php if ( 0 < count( strlen( ( $parallax_image_url = get_theme_mod( 'parallax_image' ) ) ) ) ) { ?>
        .meet-our-team-parallax {
                  background: #232222 url( <?php echo $parallax_image_url; ?> ) no-repeat fixed; 
                  background-position: center top;
                  background-blend-mode: overlay;
                  position: relative;
                  height: 240px;
                  background-repeat: no-repeat;
                  background-attachment: fixed;
                  background-size: cover;
                  line-height: 200%;
                  color: #fff;
                  overflow: hidden;
                  padding-top: 0;
                  margin-bottom: 0; 
                    }
                <?php }  

       ?>
    </style>
    <?php
}

And the JS to make the postMessage work looks like this:

wp.customize( 'parallax_image', function( value ) {
        var styles = {
                backgroundPosition: "center top",
                position: "relative",
                height: "240px",
                backgroundRepeatepeat: "no-repeat",
                backgroundAttachment: "fixed",
                backgroundSize: "cover",
                lineHeight: "200%",
                color: "#ffffff",
                overflow: "hidden",
                paddingTop: "0",
                marginBottom: "0",
                backgroundBlendMode: "overlay"
                };
        value.bind( function( to ) {
            $( '.meet-our-team-parallax ' ).css( 'background', 'url( ' + to + ')' );   
            $( '.meet-our-team-parallax ' ).css( styles ); 
        } );
    });

All the code runs ok, and the results after saving and when refreshing the actual page on the browser are the expected , but the issue is: the background-blend-mode: overlay; would not work within the Customizer when previewing real time.

Many thanks in advance.