diff --git a/_build/gpm.json b/_build/gpm.json index 4155c45..764a808 100644 --- a/_build/gpm.json +++ b/_build/gpm.json @@ -32,6 +32,9 @@ "snippets": [ { "name": "getSelections" + }, + { + "name": "renderSourceImage" } ], "systemSettings": [ @@ -115,4 +118,4 @@ "modx": ">=3.0.0-alpha" } } -} \ No newline at end of file +} diff --git a/assets/components/collections/js/mgr/extra/collections.renderers.js b/assets/components/collections/js/mgr/extra/collections.renderers.js index 714e8e6..af50624 100644 --- a/assets/components/collections/js/mgr/extra/collections.renderers.js +++ b/assets/components/collections/js/mgr/extra/collections.renderers.js @@ -163,6 +163,9 @@ collections.renderer.boolean = function(value, metaData, record, rowIndex, colIn return '
'; }; +collections.renderer.html = function(value, metaData, record, rowIndex, colIndex, store) { + return value; +}; // Backwards compatibility Collections.renderer = { diff --git a/core/components/collections/elements/snippets/renderSourceImage.php b/core/components/collections/elements/snippets/renderSourceImage.php new file mode 100644 index 0000000..5007eba --- /dev/null +++ b/core/components/collections/elements/snippets/renderSourceImage.php @@ -0,0 +1,26 @@ +getOption('value', $scriptProperties, ''); + +$tvName = $scriptProperties['column']; +$tvName = substr($tvName, 3); + +$tv = $modx->getObject(modTemplateVar::class, ['name' => $tvName]); +$tvMediaSourceId = $tv->get('source'); + +$mediaSource = $modx->getObject(modMediaSource::class, $tvMediaSourceId); +$mediaSourceProperties = $mediaSource->getProperties(); +$mediaPath = $mediaSourceProperties['basePath']['value']; + +if ($imgName) { + $thumb = $modx->runSnippet('pthumb', [ + 'input' => MODX_BASE_URL . $mediaPath . $imgName, + 'options' => '&h=90&q=75' + ]); + return ''; +} +else { + return ''; +}