diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index c4451e08ce..35baab6ab1 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -110,8 +110,9 @@ public function __construct($path) $types['alternative'][$i] = MediumFactory::scaledFromMedium($alternatives[$max]['file'], $max, $i); } - foreach ($types['alternative'] as $ratio => $altMedium) { + foreach ($types['alternative'] as $altMedium) { if ($altMedium['file'] != $medium) { + $ratio = $altMedium['file']->get('width') / $medium->get('width'); $medium->addAlternative($ratio, $altMedium['file']); } } diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index a2bb7b169a..c6c1b71809 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -497,7 +497,7 @@ public function __call($method, $args) try { call_user_func_array([$this->image, $method], $args); - foreach ($this->alternatives as $ratio => $medium) { + foreach ($this->alternatives as $medium) { if (!$medium->image) { $medium->image(); } @@ -509,7 +509,7 @@ public function __call($method, $args) if (isset(self::$magic_resize_actions[$method])) { foreach (self::$magic_resize_actions[$method] as $param) { if (isset($args_copy[$param])) { - $args_copy[$param] = (int) $args_copy[$param] * $ratio; + $args_copy[$param] *= $medium->get('ratio'); } } }