Support disks that can't be serialized in ImageResizer. (#5324)

Requires https://github.com/octobercms/library/pull/532
This commit is contained in:
Luke Towers 2020-10-22 13:20:19 -06:00 committed by GitHub
parent bd83f34ac4
commit 86496ff818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,22 +149,22 @@ class ImageResizer
'themes' => [
'disk' => 'system',
'folder' => config('cms.themesPathLocal', base_path('themes')),
'path' => config('cms.themesPath', '/themes'),
'path' => rtrim(config('cms.themesPath', '/themes'), '/'),
],
'plugins' => [
'disk' => 'system',
'folder' => config('cms.pluginsPathLocal', base_path('plugins')),
'path' => config('cms.pluginsPath', '/plugins'),
'path' => rtrim(config('cms.pluginsPath', '/plugins'), '/'),
],
'resized' => [
'disk' => config('cms.storage.resized.disk', 'local'),
'folder' => config('cms.storage.resized.folder', 'resized'),
'path' => config('cms.storage.resized.path', '/storage/app/resized'),
'path' => rtrim(config('cms.storage.resized.path', '/storage/app/resized'), '/'),
],
'media' => [
'disk' => config('cms.storage.media.disk', 'local'),
'folder' => config('cms.storage.media.folder', 'media'),
'path' => config('cms.storage.media.path', '/storage/app/media'),
'path' => rtrim(config('cms.storage.media.path', '/storage/app/media'), '/'),
],
'modules' => [
'disk' => 'system',
@ -174,7 +174,7 @@ class ImageResizer
'filemodel' => [
'disk' => config('cms.storage.uploads.disk', 'local'),
'folder' => config('cms.storage.uploads.folder', 'uploads'),
'path' => config('cms.storage.uploads.path', '/storage/app/uploads'),
'path' => rtrim(config('cms.storage.uploads.path', '/storage/app/uploads'), '/'),
],
];
@ -231,6 +231,14 @@ class ImageResizer
}
}
// Handle disks that can't be serialized by referencing them by their
// filesystems.php config name
try {
serialize($disk);
} catch (Exception $ex) {
$disk = Storage::identify($disk);
}
$config = [
'image' => [
'disk' => $disk,
@ -542,6 +550,11 @@ class ImageResizer
$path = $image['path'];
$selectedSource = $image['source'];
// Handle disks that couldn't be serialized
if (is_string($disk)) {
$disk = Storage::disk($disk);
}
// Verify that the source file exists
if (empty(FileHelper::extension($path)) || !$disk->exists($path)) {
$disk = null;