Make webp default format for images

This commit is contained in:
DariusIII
2026-07-16 15:57:20 +02:00
parent 17be0e11d2
commit b27fb8d86b
60 changed files with 1154 additions and 1136 deletions
+10 -3
View File
@@ -109,7 +109,7 @@ class AnidbInfo extends Model
*/
public function getPicturePath(): string
{
return storage_path('covers/anime/'.$this->anidbid.'.jpg');
return storage_path('covers/anime/'.$this->anidbid.'-cover.webp');
}
/**
@@ -117,7 +117,14 @@ class AnidbInfo extends Model
*/
public function hasPictureImage(): bool
{
return file_exists($this->getPicturePath());
$path = $this->getPicturePath();
$legacyPath = preg_replace('/\.webp$/', '.jpg', $path);
$oldLegacyPath = storage_path('covers/anime/'.$this->anidbid.'.jpg');
return file_exists($path)
|| (is_string($legacyPath) && file_exists($legacyPath))
|| file_exists($oldLegacyPath);
}
/**
@@ -136,7 +143,7 @@ class AnidbInfo extends Model
// Otherwise construct the local path
if ($this->hasPictureImage()) {
return url('/covers/anime/'.$this->anidbid.'.jpg');
return url('/covers/anime/'.$this->anidbid.'-cover.webp');
}
return null;
+8 -3
View File
@@ -84,7 +84,7 @@ class BookInfo extends Model
return '';
}
return storage_path('covers/book/'.$this->id.'.jpg');
return storage_path('covers/book/'.$this->id.'.webp');
}
/**
@@ -93,8 +93,13 @@ class BookInfo extends Model
public function hasCoverImage(): bool
{
$coverPath = $this->getCoverPath();
if ($coverPath === '') {
return false;
}
return $coverPath !== '' && file_exists($coverPath);
$legacyPath = preg_replace('/\.webp$/', '.jpg', $coverPath);
return file_exists($coverPath) || (is_string($legacyPath) && file_exists($legacyPath));
}
/**
@@ -106,6 +111,6 @@ class BookInfo extends Model
return null;
}
return url('/covers/book/'.$this->id.'.jpg');
return url('/covers/book/'.$this->id.'.webp');
}
}
+16 -4
View File
@@ -106,9 +106,15 @@ class GamesInfo extends Model
return null;
}
$path = config('nntmux_settings.covers_path').'/games/'.$this->id.'.jpg';
$path = config('nntmux_settings.covers_path').'/games/'.$this->id.'.webp';
return file_exists($path) ? $path : null;
if (file_exists($path)) {
return $path;
}
$legacyPath = preg_replace('/\.webp$/', '.jpg', $path);
return is_string($legacyPath) && file_exists($legacyPath) ? $legacyPath : null;
}
/**
@@ -120,8 +126,14 @@ class GamesInfo extends Model
return null;
}
$path = config('nntmux_settings.covers_path').'/games/'.$this->id.'-backdrop.jpg';
$path = config('nntmux_settings.covers_path').'/games/'.$this->id.'-backdrop.webp';
return file_exists($path) ? $path : null;
if (file_exists($path)) {
return $path;
}
$legacyPath = preg_replace('/\.webp$/', '.jpg', $path);
return is_string($legacyPath) && file_exists($legacyPath) ? $legacyPath : null;
}
}