diff --git a/src/Entity/Book.php b/src/Entity/Book.php index 0c30ff6..69ecba4 100644 --- a/src/Entity/Book.php +++ b/src/Entity/Book.php @@ -288,11 +288,10 @@ public function getIsbn() * Returns closes thumbnail size to input, default 210px. * * @param int $size appromimate size - * @param bool $ssl Whether or not to return https:// url for thumbnail * * @return string url for thumbnail */ - public function getThumbnail(int $size = 210, bool $ssl = false) + public function getThumbnail(int $size = 210) { $thumbs = []; foreach ($this->safeGet('thumbnail') as $thumb) { diff --git a/src/Entity/Journey.php b/src/Entity/Journey.php index 924dce6..0d5400e 100644 --- a/src/Entity/Journey.php +++ b/src/Entity/Journey.php @@ -100,6 +100,29 @@ public function getPublished() : string return $this->safeGet('published'); } + /** + * Returns closes thumbnail size to input, default 210px. + * + * @param int $size appromimate size + * + * @return string url for thumbnail + */ + public function getThumbnail(int $size = 210) + { + $thumbs = []; + foreach ($this->safeGet('thumbnail') as $thumb) { + $thumbs[$thumb['width']] = $thumb['_link']; + } + + $sizes = array_keys($thumbs); + while (true) { + $thumbSize = array_shift($sizes); + if ((int) $size <= (int) $thumbSize || count($sizes) === 0) { + return $thumbs[$thumbSize]; + } + } + } + /** * @return bool is featured */