Loading CHANGELOG.txt +5 −0 Original line number Diff line number Diff line Blazy 8.x-2.0-dev, 2021-04-30 ----------------------------- - Issue #3210344 by gausarts, manarak: Broken CSS background and responsive image styles with aspect ratio Fluid. Blazy 8.x-2.0-dev, 2021-04-26 ----------------------------- - Issue #3210636 by grathbone: Solution to supporting image-to-iframe embeds for Loading src/BlazyManager.php +4 −4 Original line number Diff line number Diff line Loading @@ -269,12 +269,12 @@ class BlazyManager extends BlazyManagerBase implements TrustedCallbackInterface if (!empty($settings['background'])) { $srcset = $dimensions = []; foreach ($responsive_image['styles'] as $style) { $settings = array_merge($settings, BlazyUtil::transformDimensions($style, $settings, FALSE)); $styled = array_merge($settings, BlazyUtil::transformDimensions($style, $settings, FALSE)); // Sort image URLs based on width. $data = $this->backgroundImage($settings, $style); $srcset[$settings['width']] = $data; $dimensions[$settings['width']] = $data['ratio']; $data = $this->backgroundImage($styled, $style); $srcset[$styled['width']] = $data; $dimensions[$styled['width']] = $data['ratio']; } // Sort the srcset from small to large image width or multiplier. Loading src/BlazyManagerBase.php +2 −2 Original line number Diff line number Diff line Loading @@ -400,10 +400,10 @@ abstract class BlazyManagerBase implements BlazyManagerInterface { public function setResponsiveImageDimensions(array &$settings = [], $initial = TRUE) { $srcset = []; foreach ($this->getResponsiveImageStyles($settings['resimage'])['styles'] as $style) { $settings = array_merge($settings, BlazyUtil::transformDimensions($style, $settings, $initial)); $styled = array_merge($settings, BlazyUtil::transformDimensions($style, $settings, $initial)); // In order to avoid layout reflow, we get dimensions beforehand. $srcset[$settings['width']] = round((($settings['height'] / $settings['width']) * 100), 2); $srcset[$styled['width']] = round((($styled['height'] / $styled['width']) * 100), 2); } // Sort the srcset from small to large image width or multiplier. Loading src/BlazyUtil.php +29 −15 Original line number Diff line number Diff line Loading @@ -12,6 +12,14 @@ use Drupal\image\Entity\ImageStyle; */ class BlazyUtil { /** * The image style ID. * * @var array */ private static $styleId; /** * Generates an SVG Placeholder. * Loading Loading @@ -160,9 +168,13 @@ class BlazyUtil { * Whether particularly transforms once for all, or individually. */ public static function transformDimensions($style, array $data, $initial = FALSE) { $uri = $initial ? '_uri' : 'uri'; $key = hash('md2', $style->id()); if (!isset(static::$styleId[$key])) { $width = $initial ? '_width' : 'width'; $height = $initial ? '_height' : 'height'; $uri = $initial ? '_uri' : 'uri'; $width = isset($data[$width]) ? $data[$width] : NULL; $height = isset($data[$height]) ? $data[$height] : NULL; $dim = ['width' => $width, 'height' => $height]; Loading @@ -177,7 +189,9 @@ class BlazyUtil { if ($dim['height'] != NULL) { $dim['height'] = (int) $dim['height']; } return ['width' => $dim['width'], 'height' => $dim['height']]; static::$styleId[$key] = ['width' => $dim['width'], 'height' => $dim['height']]; } return static::$styleId[$key]; } /** Loading Loading
CHANGELOG.txt +5 −0 Original line number Diff line number Diff line Blazy 8.x-2.0-dev, 2021-04-30 ----------------------------- - Issue #3210344 by gausarts, manarak: Broken CSS background and responsive image styles with aspect ratio Fluid. Blazy 8.x-2.0-dev, 2021-04-26 ----------------------------- - Issue #3210636 by grathbone: Solution to supporting image-to-iframe embeds for Loading
src/BlazyManager.php +4 −4 Original line number Diff line number Diff line Loading @@ -269,12 +269,12 @@ class BlazyManager extends BlazyManagerBase implements TrustedCallbackInterface if (!empty($settings['background'])) { $srcset = $dimensions = []; foreach ($responsive_image['styles'] as $style) { $settings = array_merge($settings, BlazyUtil::transformDimensions($style, $settings, FALSE)); $styled = array_merge($settings, BlazyUtil::transformDimensions($style, $settings, FALSE)); // Sort image URLs based on width. $data = $this->backgroundImage($settings, $style); $srcset[$settings['width']] = $data; $dimensions[$settings['width']] = $data['ratio']; $data = $this->backgroundImage($styled, $style); $srcset[$styled['width']] = $data; $dimensions[$styled['width']] = $data['ratio']; } // Sort the srcset from small to large image width or multiplier. Loading
src/BlazyManagerBase.php +2 −2 Original line number Diff line number Diff line Loading @@ -400,10 +400,10 @@ abstract class BlazyManagerBase implements BlazyManagerInterface { public function setResponsiveImageDimensions(array &$settings = [], $initial = TRUE) { $srcset = []; foreach ($this->getResponsiveImageStyles($settings['resimage'])['styles'] as $style) { $settings = array_merge($settings, BlazyUtil::transformDimensions($style, $settings, $initial)); $styled = array_merge($settings, BlazyUtil::transformDimensions($style, $settings, $initial)); // In order to avoid layout reflow, we get dimensions beforehand. $srcset[$settings['width']] = round((($settings['height'] / $settings['width']) * 100), 2); $srcset[$styled['width']] = round((($styled['height'] / $styled['width']) * 100), 2); } // Sort the srcset from small to large image width or multiplier. Loading
src/BlazyUtil.php +29 −15 Original line number Diff line number Diff line Loading @@ -12,6 +12,14 @@ use Drupal\image\Entity\ImageStyle; */ class BlazyUtil { /** * The image style ID. * * @var array */ private static $styleId; /** * Generates an SVG Placeholder. * Loading Loading @@ -160,9 +168,13 @@ class BlazyUtil { * Whether particularly transforms once for all, or individually. */ public static function transformDimensions($style, array $data, $initial = FALSE) { $uri = $initial ? '_uri' : 'uri'; $key = hash('md2', $style->id()); if (!isset(static::$styleId[$key])) { $width = $initial ? '_width' : 'width'; $height = $initial ? '_height' : 'height'; $uri = $initial ? '_uri' : 'uri'; $width = isset($data[$width]) ? $data[$width] : NULL; $height = isset($data[$height]) ? $data[$height] : NULL; $dim = ['width' => $width, 'height' => $height]; Loading @@ -177,7 +189,9 @@ class BlazyUtil { if ($dim['height'] != NULL) { $dim['height'] = (int) $dim['height']; } return ['width' => $dim['width'], 'height' => $dim['height']]; static::$styleId[$key] = ['width' => $dim['width'], 'height' => $dim['height']]; } return static::$styleId[$key]; } /** Loading