0

I'm using a studiopress theme with backstretch script already included. The site's background image is used but I'm using a content delivery network.

At present the image url is: mysite.com/media/background-image.jpg

I want it to be: cdn-url.com/media/background-image.jpg

The reason this matters is the site is hosted in Mid-West, US but has a UK audience. The CDN serves static content from London, UK.

I've posted on studiopress support forum but no reply as yet.

The current functions php code is:

//* Enqueue Backstretch script and prepare images for loading
add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' );
function agency_enqueue_backstretch_scripts() {

    //* Load scripts only if custom background is being used
    if ( ! get_background_image() )
        return;

    wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
    wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' );

    wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => str_replace( 'http:', '', get_background_image() ) ) );

}

Can this be altered to get the result I want?

1 Answers1

0

Editing the last line as below works:

wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => 'cdn_url_here' ) );