Skip to content

Instantly share code, notes, and snippets.

@chrisegg
Created March 29, 2014 05:25
Show Gist options
  • Save chrisegg/9849007 to your computer and use it in GitHub Desktop.
Save chrisegg/9849007 to your computer and use it in GitHub Desktop.
<?php
//* Do NOT include the opening php tag
//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'cegg_image_load_scripts_styles' );
function cegg_image_load_scripts_styles() {
if ( has_post_thumbnail() ) {
wp_enqueue_script( 'cegg-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0', true );
wp_enqueue_script( 'cegg-backstretch-set', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch-set.js' , array( 'jquery', 'cegg-backstretch' ), '1.0.0', true );
}
}
//* Localize backstretch script for Sales Pages
add_action( 'genesis_after_entry', 'cegg_sales_set_background_image' );
function cegg_sales_set_background_image() {
$image = array( 'src' => has_post_thumbnail() ? genesis_get_image( array( 'format' => 'url' ) ) : '' );
wp_localize_script( 'cegg-backstretch-set', 'BackStretchImg', $image );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment