Update avif support, and fix reply permalinks

pull/5828/head
Daniel Supernault 9 months ago
parent 7ddbe0c473
commit c36cc07b2c
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -1897,6 +1897,8 @@ class ApiV1Controller extends Controller
switch ($media->mime) { switch ($media->mime) {
case 'image/jpeg': case 'image/jpeg':
case 'image/png': case 'image/png':
case 'image/webp':
case 'image/avif':
ImageOptimize::dispatch($media)->onQueue('mmo'); ImageOptimize::dispatch($media)->onQueue('mmo');
break; break;
@ -2125,6 +2127,8 @@ class ApiV1Controller extends Controller
switch ($media->mime) { switch ($media->mime) {
case 'image/jpeg': case 'image/jpeg':
case 'image/png': case 'image/png':
case 'image/webp':
case 'image/avif':
ImageOptimize::dispatch($media)->onQueue('mmo'); ImageOptimize::dispatch($media)->onQueue('mmo');
break; break;

@ -133,6 +133,7 @@ class ComposeController extends Controller
case 'image/jpeg': case 'image/jpeg':
case 'image/png': case 'image/png':
case 'image/webp': case 'image/webp':
case 'image/avif':
ImageOptimize::dispatch($media)->onQueue('mmo'); ImageOptimize::dispatch($media)->onQueue('mmo');
break; break;

@ -16,70 +16,71 @@ use App\Jobs\MediaPipeline\MediaStoragePipeline;
class ImageUpdate implements ShouldQueue class ImageUpdate implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $media; protected $media;
protected $protectedMimes = [ protected $protectedMimes = [
'image/jpeg', 'image/jpeg',
'image/png', 'image/png',
'image/webp' 'image/webp',
]; 'image/avif'
];
/** /**
* Delete the job if its models no longer exist. * Delete the job if its models no longer exist.
* *
* @var bool * @var bool
*/ */
public $deleteWhenMissingModels = true; public $deleteWhenMissingModels = true;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @return void * @return void
*/ */
public function __construct(Media $media) public function __construct(Media $media)
{ {
$this->media = $media; $this->media = $media;
} }
/** /**
* Execute the job. * Execute the job.
* *
* @return void * @return void
*/ */
public function handle() public function handle()
{ {
$media = $this->media; $media = $this->media;
if(!$media) { if(!$media) {
return; return;
} }
$path = storage_path('app/'.$media->media_path); $path = storage_path('app/'.$media->media_path);
$thumb = storage_path('app/'.$media->thumbnail_path); $thumb = storage_path('app/'.$media->thumbnail_path);
if (!is_file($path)) { if (!is_file($path)) {
return; return;
} }
if((bool) config_cache('pixelfed.optimize_image')) { if((bool) config_cache('pixelfed.optimize_image')) {
if (in_array($media->mime, $this->protectedMimes) == true) { if (in_array($media->mime, $this->protectedMimes) == true) {
ImageOptimizer::optimize($thumb); ImageOptimizer::optimize($thumb);
if(!$media->skip_optimize) { if(!$media->skip_optimize) {
ImageOptimizer::optimize($path); ImageOptimizer::optimize($path);
} }
} }
} }
if (!is_file($path) || !is_file($thumb)) { if (!is_file($path) || !is_file($thumb)) {
return; return;
} }
$photo_size = filesize($path); $photo_size = filesize($path);
$thumb_size = filesize($thumb); $thumb_size = filesize($thumb);
$total = ($photo_size + $thumb_size); $total = ($photo_size + $thumb_size);
$media->size = $total; $media->size = $total;
$media->save(); $media->save();
MediaStoragePipeline::dispatch($media); MediaStoragePipeline::dispatch($media);
} }
} }

@ -28,7 +28,7 @@
<div class="media-body"> <div class="media-body">
<span class="font-weight-bold" v-pre>{{$gp->profile->username}}</span> <span class="font-weight-bold" v-pre>{{$gp->profile->username}}</span>
<div class=""> <div class="">
<p class="w-100 text-break" v-pre>{!!$gp->rendered!!}</p> <p class="w-100 text-break" v-pre>{!!$gp->caption!!}</p>
</div> </div>
<div class="mb-0 small"> <div class="mb-0 small">
<a href="{{$gp->url()}}" class="text-muted"> <a href="{{$gp->url()}}" class="text-muted">
@ -65,7 +65,7 @@
<div class="media-body"> <div class="media-body">
<span class="font-weight-bold" v-pre>{{$parent->profile->username}}</span> <span class="font-weight-bold" v-pre>{{$parent->profile->username}}</span>
<div class=""> <div class="">
<p class="w-100 text-break" v-pre>{!!$parent->rendered!!}</p> <p class="w-100 text-break" v-pre>{!!$parent->caption!!}</p>
</div> </div>
<div class="mb-0 small"> <div class="mb-0 small">
<a href="{{$parent->url()}}" class="text-muted"> <a href="{{$parent->url()}}" class="text-muted">
@ -92,7 +92,7 @@
<img class="mr-3 rounded-circle img-thumbnail" src="{{$status->profile->avatarUrl()}}" width="60px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';"> <img class="mr-3 rounded-circle img-thumbnail" src="{{$status->profile->avatarUrl()}}" width="60px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';">
<div class="media-body"> <div class="media-body">
<h5 class="mt-0 font-weight-bold" v-pre>{{$status->profile->username}}</h5> <h5 class="mt-0 font-weight-bold" v-pre>{{$status->profile->username}}</h5>
<p class="" v-pre>{!! $status->rendered !!}</p> <p class="" v-pre>{!! $status->caption !!}</p>
<div class="mb-0 small"> <div class="mb-0 small">
<a href="{{$status->url()}}" class="text-muted"> <a href="{{$status->url()}}" class="text-muted">
{{$status->created_at->diffForHumans()}} {{$status->created_at->diffForHumans()}}
@ -106,7 +106,7 @@
<img class="mr-3 rounded-circle img-thumbnail" src="{{$status->profile->avatarUrl()}}" width="60px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';"> <img class="mr-3 rounded-circle img-thumbnail" src="{{$status->profile->avatarUrl()}}" width="60px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';">
<div class="media-body"> <div class="media-body">
<h5 class="mt-0 font-weight-bold" v-pre>{{$status->profile->username}}</h5> <h5 class="mt-0 font-weight-bold" v-pre>{{$status->profile->username}}</h5>
<p class="" v-pre>{!! $status->rendered !!}</p> <p class="" v-pre>{!! $status->caption !!}</p>
<div class="mb-0 small"> <div class="mb-0 small">
<a href="{{$status->url()}}" class="text-muted"> <a href="{{$status->url()}}" class="text-muted">
{{$status->created_at->diffForHumans()}} {{$status->created_at->diffForHumans()}}

Loading…
Cancel
Save