Skip to content

Instantly share code, notes, and snippets.

@sepiariver
Created July 12, 2015 22:58
Show Gist options
  • Save sepiariver/10483240b202709f5845 to your computer and use it in GitHub Desktop.
Save sepiariver/10483240b202709f5845 to your computer and use it in GitHub Desktop.
Retrieves thumbnail paths from a json source in MODX.
<?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