From e014b1262674f2474bcaa2c39b4c8698d6b2b2b1 Mon Sep 17 00:00:00 2001 From: Gert Date: Wed, 1 Apr 2015 16:17:10 +0200 Subject: [PATCH] thumbnail selection fixes --- system/src/Grav/Common/Page/Medium/Medium.php | 2 +- .../Common/Page/Medium/ThumbnailImageMedium.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index de7e93250..b47d97791 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -265,7 +265,7 @@ class Medium extends Data implements RenderableInterface */ public function thumbnail($type = 'auto') { - if (!in_array($type, $this->thumbnailTypes)) + if ($type !== 'auto' && !in_array($type, $this->thumbnailTypes)) return $this; if ($this->thumbnailType !== $type) { diff --git a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php index ff916b4f6..3f40200cb 100644 --- a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php @@ -64,6 +64,19 @@ class ThumbnailImageMedium extends ImageMedium return $this->bubble('display', [$mode], false); } + /** + * Switch thumbnail. + * + * @param string $type + * + * @return $this + */ + public function thumbnail($type = 'auto') + { + $this->bubble('thumbnail', [$type], false); + return $this->bubble('getThumbnail', [], false); + } + /** * Turn the current Medium into a Link * @@ -100,7 +113,7 @@ class ThumbnailImageMedium extends ImageMedium protected function bubble($method, array $arguments = [], $testLinked = true) { if (!$testLinked || $this->linked) { - return call_user_func_array(array($this->parent, $method), $arguments); + return $this->parent ? call_user_func_array(array($this->parent, $method), $arguments) : $this; } else { return call_user_func_array(array($this, 'parent::' . $method), $arguments); }