mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix Fatal error on invalid image
If user has uploaded an invalid image the original code would crash when called from template
This commit is contained in:
parent
ba6078ee5b
commit
006717a3cc
@ -870,11 +870,13 @@ class UploadField extends FileField {
|
||||
$width = $this->getPreviewMaxWidth();
|
||||
$height = $this->getPreviewMaxHeight();
|
||||
if ($file->hasMethod('getThumbnail')) {
|
||||
return $file->getThumbnail($width, $height)->getURL();
|
||||
$r = $file->getThumbnail($width, $height);
|
||||
if ($r) return $r->getURL();
|
||||
} elseif ($file->hasMethod('getThumbnailURL')) {
|
||||
return $file->getThumbnailURL($width, $height);
|
||||
} elseif ($file->hasMethod('Fit')) {
|
||||
return $file->Fit($width, $height)->getURL();
|
||||
$r = $file->Fit($width, $height);
|
||||
if ($r) return $r->getURL();
|
||||
} else {
|
||||
return $file->Icon();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user