How can I json_encode the output of this function I use to get all attached images of a post?
<?php
function get_all_images($postid=0, $size='bigger', $attributes='') {
if ($postid<1) $postid = get_the_ID();
if ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => -1,
'orderby' => 'menu_order',
'post_mime_type' => 'image',)))
foreach($images as $image) {
$attachment=wp_get_attachment_image_src($image->ID, $size);
?><img src="<?php echo $attachment[0]; ?>" alt="" /><?php
}
}?>
Everything is already setup for admin-ajax.php.