Last active
August 29, 2015 14:01
-
-
Save christianseel/557a1e0f2a1f502ce1c5 to your computer and use it in GitHub Desktop.
Add this as a plugin (OnDocFormSave). Saves the first MoreGallery image into a TV (could be a hidden one) for quicker access.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the images | |
$corePath = $modx->getOption('moregallery.core_path', null, $modx->getOption('core_path') . 'components/moregallery/'); | |
$moreGallery = $modx->getService('moregallery', 'moreGallery', $corePath . 'model/moregallery/'); | |
$c = $modx->newQuery('mgImage'); | |
$c->where(array( | |
'resource' => $resource->get('id'), | |
)); | |
$c->sortby('sortorder', 'ASC'); | |
$c->limit('1'); | |
$image = $modx->getObject('mgImage', $c); | |
if($image){ | |
$image = $image->toArray(); | |
$resource->setTVValue('ref-image', $image['file_url']); | |
$resource->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've added optional output of crop images to this plugin: https://gist.github.com/pepebe/ad0217f0e8cb0ee870cb