Commit f6c0282e authored by Gaus Surahman's avatar Gaus Surahman Committed by Gaus Surahman
Browse files

- Issue #3264039 by xamount, gausarts: WSOD when using preload with a...

- Issue #3264039 by xamount, gausarts: WSOD when using preload with a responsive image style with no sizes attribute.
- Added `settings.blazies` grouping for sanity and to avoid conflict with sub-modules till all settings converted into BlazySettings at 3+.
parent 23d947f3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line

Blazy 8.x-2.0-dev, 2022-02-15
-----------------------------
- Added `settings.blazies` grouping for sanity and to avoid conflict with
  sub-modules till all settings converted into BlazySettings at 3+.
- Issue #3264039 by xamount, gausarts: WSOD when using preload with a responsive
  image style with no sizes attribute.

Blazy 8.x-2.0-dev, 2022-02-11
-----------------------------
- Moved media-related classes and services into \Drupal\blazy\Media namespace.
+20 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
/**
 * @file
 * Hooks and API provided by the Blazy module.
 *
 * @todo needs updating by the new decoupled lazy script options.
 */

/**
@@ -25,6 +27,8 @@
 *
 *     // Explicitly request for Blazy.
 *     // This allows Slick lazyLoad to not load Blazy.
 *     // May be ignored by your defined options at Blazy UI since 2.6+, unless
 *     // flagged by a bool `unlazy` in tandem with `loading` option.
 *     'lazy' => 'blazy',
 *
 *     // Optionally provide an image style. Valid URI is a must:
@@ -259,8 +263,16 @@ function hook_blazy_settings_alter(array &$build, $items) {
  // See https://drupal.org/node/2908861.
  if (isset($settings['entity_id'])
    && in_array($settings['entity_id'], [45, 67])) {
    // After blazy:2.7+.
    if (isset($settings['blazies'])) {
      $blazies = &$settings['blazies'];
      $blazies->set('ui.placeholder', '/blank.gif');
    }
    else {
      // Before blazy:2.7.
      $settings['placeholder'] = '/blank.gif';
    }
  }

  // Alternatively override views blocks identified by `current_view_mode` with
  // a blank SVG since 1px gif has issues with non-square sizes, see #2908861:
@@ -270,9 +282,17 @@ function hook_blazy_settings_alter(array &$build, $items) {
  $blazy = isset($settings['plugin_id']) && $settings['plugin_id'] == 'blazy_media';
  $rewriten = ['block_categories', 'block_popular', 'block_related'];
  if ($blazy && isset($settings['current_view_mode']) && in_array($settings['current_view_mode'], $rewriten)) {
    // After blazy:2.7+.
    if (isset($settings['blazies'])) {
      $blazies = &$settings['blazies'];
      $blazies->set('ui.placeholder', '/blank.svg');
    }
    else {
      // Before blazy:2.7.
      $settings['placeholder'] = '/blank.svg';
    }
  }
}

/**
 * Alters blazy-related formatter form elements.
+2 −1
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ load:

# Compat methods between Native and lazyload script when being ditched to enact
# lost module features: Blur, VIDEO, multi-breakpoint BG and aspect ratio.
# @todo refine to not depend on bio.media.
compat:
  js:
    js/blazy.compat.min.js: { minified: true, weight: -1.4 }
@@ -230,7 +231,7 @@ mfp:
    js/components/jquery/blazy.mfp.min.js: { minified: true }
  dependencies:
    - blazy/magnific_popup
    - blazy/compat
    # @todo revert if not enough: - blazy/compat
    - blazy/lightbox
    - blazy/media

+12 −0
Original line number Diff line number Diff line
@@ -44,6 +44,18 @@ function template_preprocess_blazy(&$variables) {
  BlazyTheme::blazy($variables);
}

/**
 * Overrides variables for image.html.twig templates.
 *
 * @todo remove when core makes `loading` attribute optional.
 */
function blazy_preprocess_image(&$variables) {
  $attributes = &$variables['attributes'];
  if (isset($attributes['data-b-unloading'])) {
    unset($attributes['loading'], $attributes['data-b-unloading']);
  }
}

/**
 * Overrides variables for responsive-image.html.twig templates.
 */
+2 −0
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ class BlazySettingsForm extends ConfigFormBase {
      '#description'   => $this->t('Enable noscript if you want to support <a href=":url">non-javascript users</a>.', [':url' => 'https://stackoverflow.com/questions/9478737']),
    ];

    // @todo remove users's consent at 3.x, should be enough with manual check.
    // It was an option due to not being fully integrated till likely 2.4+.
    $form['responsive_image'] = [
      '#type'          => 'checkbox',
      '#title'         => $this->t('Support Responsive image'),
Loading