You are here

public function BlazyFilter::cleanupNodes in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/Plugin/Filter/BlazyFilter.php \Drupal\blazy\Plugin\Filter\BlazyFilter::cleanupNodes()
1 call to BlazyFilter::cleanupNodes()
BlazyFilter::process in src/Plugin/Filter/BlazyFilter.php

File

src/Plugin/Filter/BlazyFilter.php, line 164

Class

BlazyFilter
Provides a filter to lazyload image, or iframe elements.

Namespace

Drupal\blazy\Plugin\Filter

Code

public function cleanupNodes(\DOMDocument &$dom) {
  $xpath = new \DOMXPath($dom);
  $nodes = $xpath
    ->query("//*[contains(@class, 'blazy-removed')]");
  if ($nodes->length > 0) {
    foreach ($nodes as $node) {
      if ($node->parentNode) {
        $node->parentNode
          ->removeChild($node);
      }
    }
  }
}