• 1.
    // Declare variables
  • 2.
    $imageArray = array();
  • 3.
    if(get_field('image_container')) {
  • 4.
    	while(the_repeater_field('image_container')) {
  • 5.
    		$imageSource = wp_get_attachment_image_src(get_sub_field('image'), 'full');
  • 6.
    		$thumbSource = wp_get_attachment_image_src(get_sub_field('image'), 'background_thumb');
  • 7.
    		array_push($imageArray,"{image : '" . $imageSource[0] . "', thumb : '" . $thumbSource[0] . "'}");
  • 8.
    	}
  • 9.
    }
  • 10.
     
  • 11.
    $imageOutput = implode(", ",$imageArray);
  • 12.
    		
  • 13.
    // Add some parameters for the JS.
  • 14.
    wp_localize_script(
  • 15.
    	'shutter_home',
  • 16.
    	'shutter',
  • 17.
    	array(
  • 18.
    		'imageOutputjs' => $imageOutput
  • 19.
    	)
  • 20.
    );
  • 21.
     
  • 22.
     
  • 23.
     
  • 24.
    // What is outputting in my HTML source
  • 25.
     
  • 26.
    <script type='text/javascript'>
  • 27.
    /* <![CDATA[ */
  • 28.
    var shutter = {"imageOutputjs":"{image : '\/phopaws\/assets\/0009.jpg', thumb : '\/phopaws\/assets\/0009-150x100.jpg'}, {image : '\/phopaws\/assets\/DSC_2454_bw_Gracey.jpg', thumb : '\/phopaws\/assets\/DSC_2454_bw_Gracey-150x100.jpg'}"};
  • 29.
    /* ]]> */
  • 30.
    </script>
  • 31.
     
  • 32.
     
  • 33.
     
  • 34.
    // Calling it in my JS as such with no luck
  • 35.
     
  • 36.
    // Declaring variable first
  • 37.
    var imageOutputjs = shutter.imageOutputjs;
  • 38.
     
  • 39.
     
  • 40.
    // Then outputting it in the $.supersized function
  • 41.
     
  • 42.
    // Components							
  • 43.
    slides 	:  	[
  • 44.
    			imageOutputjs
  • 45.
    			],
// Declare variables $imageArray = array(); if(get_field('image_container')) { while(the_repeater_field('image_container')) { $imageSource = wp_get_attachment_image_src(get_sub_field('image'), 'full'); $thumbSource = wp_get_attachment_image_src(get_sub_field('image'), 'background_thumb'); array_push($imageArray,"{image : '" . $imageSource[0] . "', thumb : '" . $thumbSource[0] . "'}"); } } $imageOutput = implode(", ",$imageArray); // Add some parameters for the JS. wp_localize_script( 'shutter_home', 'shutter', array( 'imageOutputjs' => $imageOutput ) ); // What is outputting in my HTML source <script type='text/javascript'> /* <![CDATA[ */ var shutter = {"imageOutputjs":"{image : '\/phopaws\/assets\/0009.jpg', thumb : '\/phopaws\/assets\/0009-150x100.jpg'}, {image : '\/phopaws\/assets\/DSC_2454_bw_Gracey.jpg', thumb : '\/phopaws\/assets\/DSC_2454_bw_Gracey-150x100.jpg'}"}; /* ]]> */ </script> // Calling it in my JS as such with no luck // Declaring variable first var imageOutputjs = shutter.imageOutputjs; // Then outputting it in the $.supersized function // Components slides : [ imageOutputjs ],

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter