You are here

public function MediaForm::getResponsiveImageOptions in GridStack 8.2

Returns Responsive image for select options.

@todo use blazy or gridstack admin if any more complex need.

1 call to MediaForm::getResponsiveImageOptions()
Form::styleForm in src/Plugin/gridstack/stylizer/Form.php

File

src/Plugin/gridstack/stylizer/MediaForm.php, line 252

Class

MediaForm
Provides the media form for Layout Builder integration.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

public function getResponsiveImageOptions() {
  if (!isset($this->responsiveImageOptions)) {
    $options = [];
    if ($this->manager
      ->getModuleHandler()
      ->moduleExists('responsive_image')) {
      $image_styles = $this->manager
        ->entityLoadMultiple('responsive_image_style');
      if (!empty($image_styles)) {
        foreach ($image_styles as $name => $image_style) {
          if ($image_style
            ->hasImageStyleMappings()) {
            $options[$name] = Html::escape($image_style
              ->label());
          }
        }
      }
    }
    $this->responsiveImageOptions = $options;
  }
  return $this->responsiveImageOptions;
}