Last active
August 29, 2015 14:23
-
-
Save jcamachott/87a49e8e7ea358b40336 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Snippet for displaying Image+ thumbnails in Collections views | |
* | |
* Based on snippet ImagePlus from @package imageplus by Alan Pich <[email protected]> | |
* @author John Camacho | |
* | |
* @snippet ImagePlus_collections | |
* @var string $tvname Name of your TV | |
* @var string $phpThumbParams Phpthumb parameters | |
* @var string $strip_text Text to remove from beginning of path, useful if you have MODX installed in a folder | |
* | |
*/ | |
$corePath = $modx->getOption('imageplus.core_path', null, $modx->getOption('core_path') . 'components/imageplus/'); | |
$imagePlus = $modx->getService('imageplus', 'ImagePlus', $corePath . 'model/imageplus/', array( | |
'core_path' => $corePath | |
)); | |
$tvname = 'product-image-thumb'; | |
$phpThumbParams = ''; | |
$strip_text = '/home/'; | |
// $tvname = $modx->getOption('tvname', $scriptProperties, '', true); | |
// $docid = $modx->getOption('docid', $scriptProperties, $modx->resource->get('id'), true); | |
// $type = $modx->getOption('type', $scriptProperties, '', true); | |
// $options = $modx->getOption('options', $scriptProperties, '', true); | |
// $tpl = $modx->getOption('tpl', $scriptProperties, 'ImagePlus.image', true); | |
$value = $modx->getOption('value', $scriptProperties, '', true); | |
if ($value) { | |
// Attempt to decode the value as json | |
$data = json_decode($value); | |
} | |
$output = ''; | |
if ($data) { | |
// Render output | |
$output = $imagePlus->getImageURL($value, array( | |
'phpThumbParams' => $phpThumbParams), $tvname | |
); | |
} | |
// strip the MODx install folder from beginning of path | |
return substr($output,strlen($strip_text)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment