BUGFIX If image does not exist in the file system, don't show a non-object error when viewing the Image/File record in AssetTableField (from r82390)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@89812 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-10-21 04:33:51 +00:00
parent 65a9830b13
commit 2436d7869a

View File

@ -157,11 +157,12 @@ class AssetTableField extends ComplexTableField {
);
$mainTab->setTitle(_t('AssetTableField.MAIN', 'Main'));
if(is_a($childData,'Image')) {
if(is_a($childData, 'Image')) {
$tab = $detailFormFields->findOrMakeTab("BottomRoot.Image", _t('AssetTableField.IMAGE', 'Image'));
$big = $childData->URL;
$thumbnail = $childData->getFormattedImage('AssetLibraryPreview')->URL;
$formattedImage = $childData->getFormattedImage('AssetLibraryPreview');
$thumbnail = $formattedImage ? $formattedImage->URL : '';
// Hmm this required the translated string to be appended to BottomRoot to add this to the Main tab
$detailFormFields->addFieldToTab('BottomRoot.Main',
@ -170,7 +171,8 @@ class AssetTableField extends ComplexTableField {
$tab->push(
new LiteralField("ImageFull",
"<img id='thumbnailImage' src='{$thumbnail}?r=" . rand(1,100000) . "' alt='{$childData->Name}' />" )
"<img id='thumbnailImage' src='{$thumbnail}?r=" . rand(1,100000) . "' alt='{$childData->Name}' />"
)
);
}