Skip to content

Commit

Permalink
Fix removing source from image TV value (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
halftrainedharry authored Aug 19, 2024
1 parent 6723a07 commit 79a6ec0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/components/fred/src/Traits/RenderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,20 @@ public function reversePreparedOutput($tv, $value, $resource)
if (!empty($value)) {
$context = !empty($resource) ? $resource->get('context_key') : $this->modx->context->get('key');
$sourceCache = $tv->getSourceCache($context);
$classKey = $sourceCache['class_key'];
$classKey = $sourceCache['source_class_key'];
if (!empty($sourceCache) && !empty($classKey)) {
if ($this->modx->loadClass($classKey)) {
$source = $this->modx->newObject($classKey);
if ($source) {
$source->fromArray($sourceCache, '', true, true);
$source->initialize();
$bases = $source->getBases();
if (!empty($bases['urlAbsolute'])) {
$url = $bases['urlAbsolute'];
if (substr($value, 0, strlen($url)) === $url) {
return substr($value, strlen($url));
}
}
$properties = $source->getPropertyList();
if (!empty($properties['baseUrl'])) {
// remove the base url from the front of the value
Expand Down

0 comments on commit 79a6ec0

Please sign in to comment.