Verified Commit 0260dfe5 authored by othermachines's avatar othermachines Committed by Osman Gormus
Browse files

Issue #3251508 by othermachines: AttributeHelper class should replace...

Issue #3251508 by othermachines: AttributeHelper class should replace array_key_exists on mixed array/Attribute object operations
parent b2c94f1d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Field\FormatterInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Template\AttributeHelper;
use Drupal\Core\Url;
use Drupal\image\Entity\ImageStyle;
use Drupal\file\Entity\File;
@@ -239,7 +240,7 @@ function lazy_process_variables(array &$variables) {
 * Implements template_preprocess_image().
 */
function lazy_preprocess_image(&$variables) {
  if (array_key_exists('data-lazy', $variables['attributes'])) {
  if (AttributeHelper::attributeExists('data-lazy', $variables['attributes'])) {
    lazy_process_variables($variables);
    // We don't need `data-lazy` attribute anymore.
    unset($variables['attributes']['data-lazy']);
@@ -250,7 +251,7 @@ function lazy_preprocess_image(&$variables) {
 * Implements template_preprocess_responsive_image().
 */
function lazy_preprocess_responsive_image(&$variables) {
  if (array_key_exists('data-lazy', $variables['attributes'])) {
  if (AttributeHelper::attributeExists('data-lazy', $variables['attributes'])) {
    // The `data-lazy` attribute will be removed in `lazy_preprocess_image()`.
    $lazy_service = \Drupal::service('lazy');
    $config = $lazy_service->getSettings();