From dd4c45fb851a56a0ab20f8010cc9b60e20b9a2bb Mon Sep 17 00:00:00 2001 From: Chewbaka69 Date: Wed, 24 Apr 2019 14:17:00 +0200 Subject: [PATCH] Add art --- fuel/app/classes/controller/cover.php | 5 ++++- fuel/app/classes/model/movie.php | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/fuel/app/classes/controller/cover.php b/fuel/app/classes/controller/cover.php index 85a1093..bd90c7a 100644 --- a/fuel/app/classes/controller/cover.php +++ b/fuel/app/classes/controller/cover.php @@ -16,13 +16,16 @@ class Controller_Cover extends Controller_Home $height = Input::get('height'); $thumb = Input::get('thumb') ?: null; + $art = Input::get('art') ?: null; $movie = Model_Movie::find_by_pk($movie_id); if(!$movie) throw new FuelException(); - if(!$thumb) + if($thumb === null && $art) + $images = $movie->getArt($width, $height); + else if($thumb === null && $art === null) $images = $movie->getCover($width, $height); else $images = $movie->getThumb($width, $height); diff --git a/fuel/app/classes/model/movie.php b/fuel/app/classes/model/movie.php index d0cf610..8195438 100644 --- a/fuel/app/classes/model/movie.php +++ b/fuel/app/classes/model/movie.php @@ -176,6 +176,29 @@ class Model_Movie extends Model_Overwrite } } + public function getArt($width = null, $height = null) + { + $path_cache = null; + $art = null; + + if(!$width && !$height) + $path_cache = '.art'; + else + $path_cache = '.art_' . $width . '_' . $height; + + try { + $art = Cache::get($this->id . $path_cache); + + if ($art) + return $art; + } catch (CacheNotFoundException $e) { + $this->getPicture($this->art, $path_cache, $width, $height); + + $art = Cache::get($this->id . $path_cache); + return $art; + } + } + /** * @return array|mixed * @throws FuelException