Moregallery first image of the resource rendered in the collections extra?

Maybe late, but I solved this if anybody still interested.
There is several unobvious bumps: to call mgGetImages you need resource id, but can’t make renderer for ‘id’ column. Id column is mandatory and used for Collections core functionality. So I used ‘Snippet Renderer’ for some unused column (e.g."class_key’):

<?php
$galleryId = $scriptProperties["row"]["id"];
$thumb = $modx->runSnippet('mgGetImages', [ 
    'resource' => $galleryId, 
    'limit' => 1,
    'imageTpl' => 'collectionsGalleryImageRenderer_tpl'
]);
return '<img src="' . $thumb . '" width="150">';

Please note you can’t use @INLINE template inside snippet call, so I used chunk ‘collectionsGalleryImageRenderer_tpl’ that returns manager thumb url:

[[+mgr_thumb]]

Unfortunately in this setup img tag would be written into Collections grid as plaintext, not html element. So I set column Renderer to ‘rawHtmlMX’ that do the magic:

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

Put this custom javascript inside file and point system setting ‘collections.user_js’ to that file (I am doing some more stuff in that file too).

2 Likes