Update image pipeline, use config_cache

This commit is contained in:
Daniel Supernault 2024-03-12 00:35:33 -06:00
parent ad506e901d
commit a72188a7db
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
6 changed files with 12 additions and 8 deletions

View file

@ -45,7 +45,7 @@ class ImageOptimize implements ShouldQueue
return; return;
} }
if(config('pixelfed.optimize_image') == false) { if((bool) config_cache('pixelfed.optimize_image') == false) {
ImageThumbnail::dispatch($media)->onQueue('mmo'); ImageThumbnail::dispatch($media)->onQueue('mmo');
return; return;
} else { } else {

View file

@ -51,7 +51,7 @@ class ImageResize implements ShouldQueue
return; return;
} }
if(!config('pixelfed.optimize_image')) { if((bool) config_cache('pixelfed.optimize_image') === false) {
ImageThumbnail::dispatch($media)->onQueue('mmo'); ImageThumbnail::dispatch($media)->onQueue('mmo');
return; return;
} }

View file

@ -61,7 +61,7 @@ class ImageUpdate implements ShouldQueue
return; return;
} }
if(config('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) {

View file

@ -98,6 +98,10 @@ class ConfigCacheService
'captcha.triggers.login.enabled', 'captcha.triggers.login.enabled',
'captcha.triggers.login.attempts', 'captcha.triggers.login.attempts',
'federation.custom_emoji.enabled', 'federation.custom_emoji.enabled',
'pixelfed.optimize_image',
'pixelfed.optimize_video',
'pixelfed.max_collection_length',
// 'system.user_mode' // 'system.user_mode'
]; ];

View file

@ -36,10 +36,10 @@ class Config
'album_limit' => (int) config_cache('pixelfed.max_album_length'), 'album_limit' => (int) config_cache('pixelfed.max_album_length'),
'image_quality' => (int) config_cache('pixelfed.image_quality'), 'image_quality' => (int) config_cache('pixelfed.image_quality'),
'max_collection_length' => (int) config('pixelfed.max_collection_length', 18), 'max_collection_length' => (int) config_cache('pixelfed.max_collection_length', 18),
'optimize_image' => (bool) config('pixelfed.optimize_image'), 'optimize_image' => (bool) config_cache('pixelfed.optimize_image'),
'optimize_video' => (bool) config('pixelfed.optimize_video'), 'optimize_video' => (bool) config_cache('pixelfed.optimize_video'),
'media_types' => config_cache('pixelfed.media_types'), 'media_types' => config_cache('pixelfed.media_types'),
'mime_types' => config_cache('pixelfed.media_types') ? explode(',', config_cache('pixelfed.media_types')) : [], 'mime_types' => config_cache('pixelfed.media_types') ? explode(',', config_cache('pixelfed.media_types')) : [],

View file

@ -750,12 +750,12 @@
<tr> <tr>
<td><span class="badge badge-primary">PIXELFED</span></td> <td><span class="badge badge-primary">PIXELFED</span></td>
<td><strong>PF_OPTIMIZE_IMAGES</strong></td> <td><strong>PF_OPTIMIZE_IMAGES</strong></td>
<td><span>{{config_cache('pixelfed.optimize_image') ? '✅ true' : '❌ false' }}</span></td> <td><span>{{(bool) config_cache('pixelfed.optimize_image') ? '✅ true' : '❌ false' }}</span></td>
</tr> </tr>
<tr> <tr>
<td><span class="badge badge-primary">PIXELFED</span></td> <td><span class="badge badge-primary">PIXELFED</span></td>
<td><strong>PF_OPTIMIZE_VIDEOS</strong></td> <td><strong>PF_OPTIMIZE_VIDEOS</strong></td>
<td><span>{{config_cache('pixelfed.optimize_video') ? '✅ true' : '❌ false' }}</span></td> <td><span>{{(bool) config_cache('pixelfed.optimize_video') ? '✅ true' : '❌ false' }}</span></td>
</tr> </tr>
<tr> <tr>
<td><span class="badge badge-primary">PIXELFED</span></td> <td><span class="badge badge-primary">PIXELFED</span></td>