mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-14 10:34:31 +00:00
Update Image media util, store dimensions of media not thumbnail
This commit is contained in:
parent
cf40526ef9
commit
40bd64aae7
1 changed files with 10 additions and 8 deletions
|
@ -4,7 +4,7 @@ namespace App\Util\Media;
|
||||||
|
|
||||||
use App\Media;
|
use App\Media;
|
||||||
use Image as Intervention;
|
use Image as Intervention;
|
||||||
use Cache, Storage;
|
use Cache, Log, Storage;
|
||||||
|
|
||||||
class Image
|
class Image
|
||||||
{
|
{
|
||||||
|
@ -165,30 +165,32 @@ class Image
|
||||||
|
|
||||||
$quality = config('pixelfed.image_quality');
|
$quality = config('pixelfed.image_quality');
|
||||||
$img->save($newPath, $quality);
|
$img->save($newPath, $quality);
|
||||||
$media->width = $img->width();
|
|
||||||
$media->height = $img->height();
|
|
||||||
$img->destroy();
|
|
||||||
if (!$thumbnail) {
|
|
||||||
$media->orientation = $orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($thumbnail == true) {
|
if ($thumbnail == true) {
|
||||||
$media->thumbnail_path = $converted['path'];
|
$media->thumbnail_path = $converted['path'];
|
||||||
$media->thumbnail_url = url(Storage::url($converted['path']));
|
$media->thumbnail_url = url(Storage::url($converted['path']));
|
||||||
} else {
|
} else {
|
||||||
|
$media->width = $img->width();
|
||||||
|
$media->height = $img->height();
|
||||||
|
$media->orientation = $orientation;
|
||||||
$media->media_path = $converted['path'];
|
$media->media_path = $converted['path'];
|
||||||
$media->mime = $img->mime;
|
$media->mime = $img->mime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$img->destroy();
|
||||||
$media->save();
|
$media->save();
|
||||||
|
|
||||||
if($thumbnail) {
|
if($thumbnail) {
|
||||||
$this->generateBlurhash($media);
|
$this->generateBlurhash($media);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::forget('status:transformer:media:attachments:'.$media->status_id);
|
Cache::forget('status:transformer:media:attachments:'.$media->status_id);
|
||||||
Cache::forget('status:thumb:'.$media->status_id);
|
Cache::forget('status:thumb:'.$media->status_id);
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
$media->processed_at = now();
|
||||||
|
$media->save();
|
||||||
|
Log::info('MediaResizeException: Could not process media id: ' . $media->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue