Forked from sepiariver/getResourceImage.snippet.php
Created
December 21, 2017 12:09
-
-
Save Burick/19ae7d33521369d2475c9ed7074e7b7e 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