Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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