mirror of
https://github.com/getgrav/grav.git
synced 2026-07-20 00:41:55 +02:00
Use correct ratio when applying image filters to image alternatives (#1147)
Because of a previous change, the keys of the image alternatives array is no longer the ratio, but rather the image width. We now make sure to calculate the ratio correctly and use the appropriate one when applying the image filters.
This commit is contained in:
committed by
Flavio Copes
parent
76aed8a119
commit
58d4e3384e
@@ -110,8 +110,9 @@ class Media extends Getters
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ class ImageMedium extends Medium
|
||||
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 @@ class ImageMedium extends Medium
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user