Collections Custom renderer display HTML code but not the image

Hello

Using MODX Collections 4.0.0 beta1 Extra with MODX 3.0.1
When i choose collections.renderer.image, the preview is broken in the resource manager page because the image path is wrong :

the thumbnail src shows :
https://dev.kurtzdev.com/ecosave/prestations/management-environnemental.jpg

but it should be :
https://dev.kurtzdev.com/ecosave/assets/components/ecosave/images/prestations/management-environnemental.jpg

So i tried with a custom image renderer but it display the HTML code without interpreting it !
The thumbnail generation is OK but,
the image column in the resource manager page show the HTML code and not the preview.

<img src="/ecosave/assets/components/phpthumbof/cache/dossier-icpe.c1774bf5969c33d0d2f149847a0077f0.jpg" width="60">

the custom render snippet :

<?php
// Snippet customThumbnailRenderer
$imgName = $modx->getOption('value', $scriptProperties, '');
$imgPath = 'https://dev.kurtzdev.com/ecosave/assets/components/ecosave/images/';
$thumb = $modx->runSnippet('pthumb', [ 
    'input' => $imgPath . $imgName, 
    'options' => '&w=60&h=60&zc=C' 
]);
return '<img src="' . $thumb . '" width="60">';

Can anyone help me with this ?
Thank you in advance
/.

With the default collections.renderer.image renderer, you should be able to set the system setting collections.renderer_image_path to a value like assets/components/ecosave/images/ to make it work.

1 Like

OK, it works fine !
Why is it so simple ?
i feel stupid now ! :roll_eyes:

THANK YOU !

*but it doesn’t answer the question “why custom renderer show the HTML code ?” *
isn’t this a bug ?

Yes, I’m pretty sure this used to work in earlier versions.


As a workaround you could create a simple custom JS renderer in a *.js file like

collections.renderer.just_output_my_value_as_markup = function(value, metaData, record, rowIndex, colIndex, store) {
    return value;
};

then set the system setting collections.user_js to the url of this file
and set collections.renderer.just_output_my_value_as_markup as the renderer of your image-column.

1 Like