but how do i get now the binary data for further processing (either in the controller to modify the thumbnail or directly in the fluid template to display as base64 encoded inline image)?
all i get is a “resource”, but i have not found anything about how to access the data of this resource :((((
Hi glad you found a way
Often clicking with your ide (phpStorm ^^) through the source code is the best guide one gets, as thats a very specific task ^^
I dont really know all about fluids default viewhelpers - but my guess is, that fluid doesnt have a viewhelper for this so A: you need to create a new view helper, or B: separate this concern into your php integration, and pass a fluid variable…
yes, this is the way i’m currently doing this, but the problem is, that there’s not just a single image to render (because i get a resultset of notes, and each note has an image), so i have to modify/copy the resultset, and that’s not handy …
$n2 = [];
for ($repo->findNotes() as $note) {
$n2[] = ['id' => $note->getId(), 'thumbnail' => base64_encode(stream_get_contents($note->getThumbnail()))];
}
$this->view->assign('notes', $n2);
but i thought about something like (without the code above)
<f:for each="{notes}" as "note">
<td>{note.id}</td>
<td><img src="data:image/jpeg,base64, <f:doAnythingWithTheResource>{note.thumbnail}</f:doAnythingWithTheResource>"></td>
</f:for>
but it seems there is no builtin function/helper, so i would have to create my own ViewHelper, correct?
You thumbnail variable seems to be the result of your base64_encode method - so it’s a string.
If that is true, you don’t need to do anything, and you rendering would look like
<f:for each="{notes}" as "note">
<td>{note.id}</td>
<td><img src="data:image/jpeg,base64, {note.thumbnail}"></td>
</f:for>
So, without any custom viewhelper - doesn’t that do the trick for you?
Note: Many base64 datauris in a single page, can really be a pain for the browser to render (you are putting the load on the CPU/GPU of the clients computer).
i dont want to make a clone of the requestquery $notes to an array $n2 and converting all the the binary thumbnail properties to base64-encoded properties. and if i assign a object with a binary property to the view, i would need some kind of funktion to convert the binary to base64 - a built in function or a viewhelper …
i changed the source to NOT embed the base64-images as you mentioned - but not for the reason of CPU-load (the page designed is only for some administrators and not for the public, so CPU-power is not a question) , but other reasons.
but then a new question arose: how to output binary data in neos flow? i know how to render json-data (Model View Controller — Flow Framework dev-master documentation) but what about binary data? i haven’t found anything, so i make the output with a “primitive” view and f:format.raw - is there a better way?