• Hi,

    Currently in my theme, backstretch.js pulls the image info from the featured image to display as the background. I want this to continue, but i want a second featured image to display when people share the posts on social networks.

    The easiest way, I think, is to change it so the backstretch pulls the image from the second featured image instead and the social networks do their normal thing of taking the first featured image.

    My question is,.. what do I change so backstretch looks for the second image instead of the first? The current code relating to this is this.. I’m pretty sure just one bit needs changing, but I am having no luck. I thought you may spot it in a couple of seconds.

    Thanks.

    if ( is_singular() ) {
    		wp_enqueue_script( 'backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/jquery.backstretch.min.js', array( 'jquery' ), '1.0.0' );
    wp_enqueue_script( 'backstretch-set3', get_bloginfo('stylesheet_directory').'/js/backstretch-set3.js' , array( 'jquery', 'backstretch' ), '1.0.0' );
    wp_localize_script( 'backstretch-set3', 'BackStretchImg', array( 'src' => wp_get_attachment_url( get_post_thumbnail_id() ) ) );
    		}
    
    }
    
    //* Localize backstretch script
    add_action( 'genesis_after_entry', 'ambiance_set_background_image' );
    function ambiance_set_background_image() {
    
    	$image = array( 'src' => has_post_thumbnail() ? genesis_get_image( array( 'format' => 'url' ) ) : '' );
    
    	wp_localize_script( 'ambiance-backstretch-set', 'BackStretchImg', $image );
    
    }

    https://wordpress.org/plugins/dynamic-featured-image/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Using with Backstretch.js?’ is closed to new replies.