laravel-paperclip
laravel-paperclip copied to clipboard
Re-uploading of image attachment with variants - variants have incorrect extension
I added variants to my model's paperclip config and encountered a problem when re-uploading images. Original was uploaded as expected, but variants were uploaded with incorrect extension (from previous version).
Example: Firstly I uploaded image image.png
and everything was good. Original and variants were uploaded and saved.
Later I decided to replace image to image.jpg
and original was uploaded correctly, but variants had incorrect extension png
from previous version.
I guess problem in methods variantFilename()
of AttachmentData
and Attachment
classes. They return different results after interpolation. AttachmentData
class returns path based on previous version of attachment, even in case of re-uploading.
Config:
$this->hasAttachedFile('logo', [
'storage' => 's3',
'variants' => [
Variant::make('thumb')->steps([
ResizeStep::make()->square(100)
]),
Variant::make('small')->steps([
ResizeStep::make()->square(300)
]),
],
'attributes' => [
'variants' => true,
'file_size' => false,
'content_type' => false
]
]);