Skip to content

Commit

Permalink
Update ImageOptimizePipeline, improve support for disabling image opt…
Browse files Browse the repository at this point in the history
…imizations
  • Loading branch information
dansup committed Apr 9, 2023
1 parent 153cea4 commit e76289e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
12 changes: 7 additions & 5 deletions app/Jobs/ImageOptimizePipeline/ImageOptimize.php
Expand Up @@ -39,16 +39,18 @@ public function __construct(Media $media)
*/
public function handle()
{
if(config('pixelfed.optimize_image') == false) {
return;
}

$media = $this->media;
$path = storage_path('app/'.$media->media_path);
if (!is_file($path) || $media->skip_optimize) {
return;
}

ImageResize::dispatch($media)->onQueue('mmo');
if(config('pixelfed.optimize_image') == false) {
ImageThumbnail::dispatch($media)->onQueue('mmo');
return;
} else {
ImageResize::dispatch($media)->onQueue('mmo');
return;
}
}
}
4 changes: 4 additions & 0 deletions app/Jobs/ImageOptimizePipeline/ImageResize.php
Expand Up @@ -49,6 +49,10 @@ public function handle()
return;
}

if(!config('pixelfed.optimize_image')) {
ImageThumbnail::dispatch($media)->onQueue('mmo');
return;
}
try {
$img = new Image();
$img->resizeImage($media);
Expand Down
10 changes: 6 additions & 4 deletions app/Jobs/ImageOptimizePipeline/ImageUpdate.php
Expand Up @@ -61,10 +61,12 @@ public function handle()
return;
}

if (in_array($media->mime, $this->protectedMimes) == true) {
ImageOptimizer::optimize($thumb);
if(!$media->skip_optimize) {
ImageOptimizer::optimize($path);
if(config('pixelfed.optimize_image')) {
if (in_array($media->mime, $this->protectedMimes) == true) {
ImageOptimizer::optimize($thumb);
if(!$media->skip_optimize) {
ImageOptimizer::optimize($path);
}
}
}

Expand Down

1 comment on commit e76289e

@lapineige
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what is the result of this change for end users ? 🙏

Do we have anything to change on our side ?

Please sign in to comment.