I need to convert a list of images from within a channel entries loop to base64.
I think I can do it with php basically like this:
<?php
$encodedImages = array(
'assets/test-image-1.jpg',
'assets/test-image-2.jpg',
'assets/test-image-4.jpg',
'assets/test-image-5.jpg',
);
if (isset($_GET['id']) && in_array($_GET['id'], $encodedImages)) {
echo 'data:image/jpg;base64,' . base64_encode(file_get_contents(realpath( './' . $_GET['id'])));
}
?>but I need to get the image path from my channel entry data into a php array.
I can output a list of image paths in an EE template using the code below, but I’m not sure how to combine the two bits of code to encode the images (or if it is even possible). Has anyone done something like this?
{exp:channel:entries channel="pages"}
'{image}',
{/exp:channel:entries}