diff --git a/CHANGELOG.md b/CHANGELOG.md index fa6da90fc6..974ff630a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#bugfix) * Fixed an issue with theme inheritance and hyphenated base themes [#1353](https://github.com/getgrav/grav/issues/1353) + * Fixed an issue when trying to use an `@2x` derivative on a non-image media file [#1341](https://github.com/getgrav/grav/issues/1341) # v1.2.0-rc.1 ## 03/13/2017 diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index eb12eeb1cb..34396bff37 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -141,8 +141,12 @@ protected function init() foreach ($types['alternative'] as $altMedium) { if ($altMedium['file'] != $medium) { - $ratio = $altMedium['file']->get('width') / $medium->get('width'); - $medium->addAlternative($ratio, $altMedium['file']); + $altWidth = $altMedium['file']->get('width'); + $medWidth = $medium->get('width'); + if ($altWidth && $medWidth) { + $ratio = $altWidth / $medWidth; + $medium->addAlternative($ratio, $altMedium['file']); + } } } }