Bruno17/multiItemsGridTV — Issue #38: Images with DataSources Modx 2.2
Author: oilee80
Created: 2012-02-23 21:41:03+00:00
State: open

Made an amend to the snippet to resolve this, the original one didn't use the data source for the image

Amend is as follows:
************************************
if ($tv = $modx->getObject('modTemplateVar',array('name' => $inputTvs[$field]['inputTV']))) {
$inputTV = $inputTvs[$field];
$mTypes = $modx->getOption('manipulatable_url_tv_output_types', null, 'image,file');
//don't manipulate any urls here
//	$modx->setOption('manipulatable_url_tv_output_types', '');
$modx->setOption('manipulatable_url_tv_output_types', $mTypes);
$tv->set('default_text', $value);
//	$value = $tv->renderOutput($docid);
$value = $tv->renderOutput(false);
//set option back
// Copied to above renderOutput()
//	$modx->setOption('manipulatable_url_tv_output_types', $mTypes);
/* This dosnt seem to be needed (at least in 2.2 as is handled in $tv->getValue() (called by renderOutput))
//now manipulate urls
if ($mediasource = $migx->getFieldSource($inputTV, $tv)) {
$mTypes = explode(',', $mTypes);
if (!empty($value) && in_array($tv->get('type'), $mTypes)) {
//setPlaceholders for sourcePath replacements
$modx->setPlaceholder('mediasource.res_id',$docid);
$value = $mediasource->prepareOutputUrl($value);
}
}*/
}}
$fields[$field] = $value;
************************************