You are here

public function BlazyFilter::buildSettings in Blazy 7

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

File

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

Class

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

Namespace

Drupal\blazy\Plugin\Filter

Code

public function buildSettings(array &$settings, $node) {
  $settings['_check_protocol'] = TRUE;
  $width = $node
    ->getAttribute('width');
  $height = $node
    ->getAttribute('height');
  $src = $node
    ->getAttribute('src');
  if ($src && $node->tagName == 'img') {
    $abs_url = strpos($src, 'http') === FALSE ? DRUPAL_ROOT . $src : $src;
    if (!$width && ($data = @getimagesize($abs_url))) {
      list($width, $height) = $data;
    }
  }
  $settings['width'] = $width;
  $settings['height'] = $height;
  $settings['ratio'] = !$width ? '' : 'fluid';
}