[StoreRemoteMedia] Gracefully recover from poorly encoded images
This commit is contained in:
parent
b96a44c73f
commit
5582ccfcb7
@ -300,6 +300,7 @@ class StoreRemoteMediaPlugin extends Plugin
|
|||||||
|
|
||||||
// If the image is not of the desired size, resize it
|
// If the image is not of the desired size, resize it
|
||||||
if (!$this->store_original && $this->crop && ($info[0] > $this->thumbnail_width || $info[1] > $this->thumbnail_height)) {
|
if (!$this->store_original && $this->crop && ($info[0] > $this->thumbnail_width || $info[1] > $this->thumbnail_height)) {
|
||||||
|
try {
|
||||||
// Temporary object, not stored in DB
|
// Temporary object, not stored in DB
|
||||||
$img = new ImageFile(-1, $fullpath);
|
$img = new ImageFile(-1, $fullpath);
|
||||||
list($width, $height, $x, $y, $w, $h) = $img->scaleToFit($this->thumbnail_width, $this->thumbnail_height, $this->crop);
|
list($width, $height, $x, $y, $w, $h) = $img->scaleToFit($this->thumbnail_width, $this->thumbnail_height, $this->crop);
|
||||||
@ -314,6 +315,10 @@ class StoreRemoteMediaPlugin extends Plugin
|
|||||||
$width = $box['width'];
|
$width = $box['width'];
|
||||||
$height = $box['height'];
|
$height = $box['height'];
|
||||||
$img->resizeTo($fullpath, $box);
|
$img->resizeTo($fullpath, $box);
|
||||||
|
} catch (\Intervention\Image\Exception\NotReadableException $e) {
|
||||||
|
common_log(LOG_ERR, "StoreRemoteMediaPlugin::storeRemoteThumbnail was unable to decode image with Intervention: $e");
|
||||||
|
// No need to interrupt processing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new AlreadyFulfilledException('A thumbnail seems to already exist for remote file' .
|
throw new AlreadyFulfilledException('A thumbnail seems to already exist for remote file' .
|
||||||
|
Loading…
Reference in New Issue
Block a user