mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Make webp default format for images
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user