Created
July 12, 2015 22:58
-
-
Save sepiariver/10483240b202709f5845 to your computer and use it in GitHub Desktop.
Retrieves thumbnail paths from a json source in MODX.
This file contains hidden or 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
<?php | |
// Options | |
$input = $modx->getOption('input', $scriptProperties, ''); | |
if (empty($input)) return; | |
$size = $modx->getOption('size', $scriptProperties, 'original'); | |
$toPlaceholder = $modx->getOption('toPlaceholder', $scriptProperties, ''); | |
// Get stuff | |
$image = $modx->fromJSON($input); | |
if (!is_array($image)) return; | |
// Do stuff | |
$result = ($size === 'original') ? $image['original'] : $image['thumbs'][$size]; | |
// Bring it | |
if (empty($toPlaceholder)) return $result; | |
$modx->setPlaceholder($toPlaceholder, $result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment