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

**URL:** <https://forum.modmore.com/t/moregallery-first-image-of-the-resource-rendered-in-the-collections-extra/304>\
**Category:** MoreGallery\
**Created:** [May 4, 2016, 11:34am UTC](https://forum.modmore.com/t/moregallery-first-image-of-the-resource-rendered-in-the-collections-extra/304 "2016-05-04T11:34:50Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![hrabovec](https://forum.modmore.com/letter_avatar_proxy/v4/letter/h/e9c0ed/32.png) [@hrabovec](https://forum.modmore.com/u/hrabovec)\
**Post date:** [February 5, 2024, 2:01pm UTC](https://forum.modmore.com/t/moregallery-first-image-of-the-resource-rendered-in-the-collections-extra/304/9 "2024-02-05T14:01:19Z")

</div>

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’):

```auto
<?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:

```auto
[[+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:

```auto
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).

---

_[View the full topic](https://forum.modmore.com/t/moregallery-first-image-of-the-resource-rendered-in-the-collections-extra/304)._
