Stopped invalid derivates throwing fatal error #1341

This commit is contained in:
Andy Miller
2017-03-15 18:15:34 -06:00
parent 262951ece4
commit 252b2f71a0
2 changed files with 7 additions and 2 deletions

View File

@@ -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

View File

@@ -141,8 +141,12 @@ class Media extends AbstractMedia
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']);
}
}
}
}