Skip to content

Commit

Permalink
Stopped invalid derivates throwing fatal error #1341
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Mar 16, 2017
1 parent 262951e commit 252b2f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions system/src/Grav/Common/Page/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}
}
}
Expand Down

0 comments on commit 252b2f7

Please sign in to comment.