Update Image media util, store dimensions of media not thumbnail

This commit is contained in:
Daniel Supernault 2021-01-19 19:36:05 -07:00
parent cf40526ef9
commit 40bd64aae7
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -4,7 +4,7 @@ namespace App\Util\Media;
use App\Media;
use Image as Intervention;
use Cache, Storage;
use Cache, Log, Storage;
class Image
{
@ -165,30 +165,32 @@ class Image
$quality = config('pixelfed.image_quality');
$img->save($newPath, $quality);
$media->width = $img->width();
$media->height = $img->height();
$img->destroy();
if (!$thumbnail) {
$media->orientation = $orientation;
}
if ($thumbnail == true) {
$media->thumbnail_path = $converted['path'];
$media->thumbnail_url = url(Storage::url($converted['path']));
} else {
$media->width = $img->width();
$media->height = $img->height();
$media->orientation = $orientation;
$media->media_path = $converted['path'];
$media->mime = $img->mime;
}
$img->destroy();
$media->save();
if($thumbnail) {
$this->generateBlurhash($media);
}
Cache::forget('status:transformer:media:attachments:'.$media->status_id);
Cache::forget('status:thumb:'.$media->status_id);
} catch (Exception $e) {
$media->processed_at = now();
$media->save();
Log::info('MediaResizeException: Could not process media id: ' . $media->id);
}
}