Created
March 24, 2017 13:52
-
-
Save celticwebdesign/70e42def04582e704f0f2b30deab4f98 to your computer and use it in GitHub Desktop.
PHP encoding an array or arrays into JSON for JS Slideshow plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_pop_up($ID) { | |
$rows_fss = get_field('slideshow_repeater',$ID); | |
$output = ""; | |
if($rows_fss) { | |
$output .= "<div id='inline1' style='display: none;'>"; | |
$output .= "<div data-src='"; | |
$images_array = array(); | |
foreach($rows_fss as $row_fss) { | |
$image_attributes = wp_get_attachment_image_src( $row_fss['slide_photo'], 'large' ); | |
array_push($images_array, | |
array( | |
"src" => $image_attributes[0], | |
"wid" => $image_attributes[1], | |
"hei" => $image_attributes[2], | |
"cap" => htmlspecialchars($row_fss['slide_title'], ENT_QUOTES) | |
) | |
); | |
} | |
$output .= json_encode($images_array); | |
$output .= " | |
'></div>"; | |
$output .="</div>"; | |
} | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment