Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’

Luckily, I was facing the same issue an hour ago so I brainstormed for a long time to find a find a solution. I posted it here before seeing this: http://www.hardeepasrani.com/2015/12/using-postmessage-transport-method-for-header-image/

So instead of just using:

$wp_customize->get_setting( 'header_image' )->transport="postMessage";

I used:

$wp_customize->get_setting( 'header_image'  )->transport="postMessage";
$wp_customize->get_setting( 'header_image_data'  )->transport="postMessage";

After that, in JS, we got the value using header_image.

Hope it helps you. 🙂

Leave a Comment