Update avif support, and fix reply permalinks

pull/5828/head
Daniel Supernault 2 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) {
case 'image/jpeg':
case 'image/png':
case 'image/webp':
case 'image/avif':
ImageOptimize::dispatch($media)->onQueue('mmo');
break;
@ -2125,6 +2127,8 @@ class ApiV1Controller extends Controller
switch ($media->mime) {
case 'image/jpeg':
case 'image/png':
case 'image/webp':
case 'image/avif':
ImageOptimize::dispatch($media)->onQueue('mmo');
break;

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

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

@ -28,7 +28,7 @@
<div class="media-body">
<span class="font-weight-bold" v-pre>{{$gp->profile->username}}</span>
<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 class="mb-0 small">
<a href="{{$gp->url()}}" class="text-muted">
@ -65,7 +65,7 @@
<div class="media-body">
<span class="font-weight-bold" v-pre>{{$parent->profile->username}}</span>
<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 class="mb-0 small">
<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';">
<div class="media-body">
<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">
<a href="{{$status->url()}}" class="text-muted">
{{$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';">
<div class="media-body">
<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">
<a href="{{$status->url()}}" class="text-muted">
{{$status->created_at->diffForHumans()}}

Loading…
Cancel
Save