Skip to content

Commit

Permalink
Merge pull request #50 from bookboon/hotfix/journey-thumb
Browse files Browse the repository at this point in the history
Add getting for journey image
  • Loading branch information
lkm committed Feb 21, 2020
2 parents fcfab22 + e1a3ced commit b9cfca3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Entity/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
23 changes: 23 additions & 0 deletions src/Entity/Journey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit b9cfca3

Please sign in to comment.