[ENTITY][AttachmentThumbnail] Now thumbnails are always only available in three sizes: small, medium, big

Commit jointly produced with eli (Eliseu Amaro)

Breaking change: Entity changed to only store the tinyint referring to the size stored

With this, the logic was simplified and now it's not possible to make an
instance produce unnecessary thumbs. The aspect ratio is preserved and
thus the thumbs will always look nice. New configuration was added to
maintain flexibility.
This commit is contained in:
2021-09-22 15:08:30 +01:00
parent 7beb5c2995
commit 05f16a3084
7 changed files with 121 additions and 193 deletions

View File

@@ -157,7 +157,7 @@ class StoreRemoteMedia extends Plugin
// Create an attachment for this
$temp_file = new TemporaryFile();
$temp_file->write($media);
$attachment = GSFile::sanitizeAndStoreFileAsAttachment($temp_file);
$attachment = GSFile::storeFileAsAttachment($temp_file);
// Relate the link with the attachment
DB::persist(AttachmentToLink::create([
@@ -177,8 +177,7 @@ class StoreRemoteMedia extends Plugin
if (!$this->getStoreOriginal()) {
$thumbnail = AttachmentThumbnail::getOrCreate(
attachment: $attachment,
width: $this->getThumbnailWidth(),
height: $this->getThumbnailHeight(),
size: 'small',
crop: $this->getSmartCrop()
);
$attachment->deleteStorage();