Index: branches/5.1.x/core/units/images/image_tag_processor.php =================================================================== diff -u -N -r13086 -r13545 --- branches/5.1.x/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 13086) +++ branches/5.1.x/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 13545) @@ -1,6 +1,6 @@ SetDBField('Url', $parent_item->GetDBField('FullUrl')); - $object->SetDBField('AltName', $this->getItemTitle($parent_item)); - $object->SetDBFieldsFromHash($parent_item->GetFieldValues(), Array('SameImages', 'LocalThumb', 'ThumbPath', 'ThumbUrl', 'LocalImage', 'LocalPath')); + $object->SetDBFieldsFromHash($parent_item->GetFieldValues(), Array('AltName', 'SameImages', 'LocalThumb', 'ThumbPath', 'ThumbUrl', 'LocalImage', 'LocalPath')); + + if (!$object->GetDBField('AltName')) { + $object->SetDBField('AltName', $this->getItemTitle($parent_item)); + } + $object->Loaded = true; } @@ -214,10 +218,11 @@ // show "noimage.gif" when requested image is missing OR was not uploaded $use_default_image = !(defined('DBG_IMAGE_RECOVERY') && DBG_IMAGE_RECOVERY); - $base_url = rtrim($this->Application->BaseURL(), '/'); - if (!$object->isLoaded() || ($object->GetDBField('SameImages') && $object->GetDBField('ThumbPath'))) { - // we can auto-resize image, when source image available & we use same image for thumbnail & full image in admin + $src_image_url = $this->_getImageUrl($params); + $src_image = $this->_getImagePath($src_image_url); + if (!$object->isLoaded() || ($src_image_url && $src_image)) { + // we can auto-resize image, when it is stored locally $max_width = $this->getImageDimension('Width', $params); $max_height = $this->getImageDimension('Height', $params); $format = array_key_exists('format', $params) ? $params['format'] : false; @@ -228,7 +233,6 @@ } if ($max_width > 0 || $max_height > 0 || $format) { - $src_image = FULL_PATH.$object->GetDBField('ThumbPath'); list ($max_width, $max_height) = $this->_transformParams($params, $max_width, $max_height); if ($object->isLoaded() && file_exists($src_image)) { @@ -241,10 +245,50 @@ return $this->_getDefaultImage($params, $max_width, $max_height); } - return $base_url . $object->GetDBField('ThumbPath'); + return $src_image_url; } } + if ($src_image_url) { + // convert full url to full path! + $dst_image = $this->_getImagePath($src_image_url); + $image_found = $dst_image ? file_exists($dst_image) : true; + + if ($image_found) { + // image isn't deleted OR is stored on remote location + return $src_image_url; + } + } + + // return Default Image or false if NOT specified (only for case, when SameImages = 0) + return $use_default_image ? $this->_getDefaultImage($params) : $src_image_url; + } + + /** + * Get location on disk for images, stored locally and false for remote images + * + * @param string $src_image + * @return string + */ + function _getImagePath($src_image) + { + if (!$src_image) { + return false; + } + + $base_url = rtrim($this->Application->BaseURL(), '/'); + $dst_image = preg_replace('/^' . preg_quote($base_url, '/') . '/', FULL_PATH, $src_image, 1); + + return $dst_image != $src_image ? $dst_image : false; + } + + function _getImageUrl($params) + { + $object =& $this->getObject($params); + /* @var $object kDBItem */ + + $base_url = rtrim($this->Application->BaseURL(), '/'); + // if we need thumbnail, or full image is same as thumbnail $show_thumbnail = $this->SelectParam($params, 'thumbnail,Thumbnail') || // old style (isset($params['MaxWidth']) && $params['MaxWidth'] == 'thumbnail') || // new style @@ -258,19 +302,7 @@ $ret = $object->GetDBField('LocalImage') ? $base_url . $object->GetDBField('LocalPath') : $object->GetDBField('Url'); } - if ($ret && ($ret != $base_url)) { - // convert full url to full path! - $dst_image = preg_replace('/^' . preg_quote($base_url, '/') . '/', FULL_PATH, $ret, 1); - $image_found = $dst_image != $ret ? file_exists($dst_image) : true; - - if ($image_found) { - // image isn't deleted OR is stored on remote location - return $ret; - } - } - - // return Default Image or false if NOT specified (only for case, when SameImages = 0) - return $this->_getDefaultImage($params); + return $ret == $base_url ? '' : $ret; } /**