How can I json_encode the output of my function?

Not sure if the get_all_images() function is the one that is added to your wp_ajax_{action} hook. If it is you will want to output a string back to your js. I would define a variable and concatenate the img html to it as you loop through your images.

function get_all_images() {
//your code
$response="";
foreach($images as $image) {
        $attachment=wp_get_attachment_image_src($image->ID, $size);

        $response .= '<img src="'.$attachment[0].'" alt="" />';
    }

 die( json_encode( $response ) );

}

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş