getFallbackImageStyle example

public function getImageStyleMapping($breakpoint_id$multiplier) {
    $map = $this->getKeyedImageStyleMappings();
    if (isset($map[$breakpoint_id][$multiplier])) {
      return $map[$breakpoint_id][$multiplier];
    }
  }

  /** * {@inheritdoc} */
  public function getImageStyleIds() {
    $image_styles = [$this->getFallbackImageStyle()];
    foreach ($this->getImageStyleMappings() as $image_style_mapping) {
      // Only image styles of non-empty mappings should be loaded.       if (!$this::isEmptyImageStyleMapping($image_style_mapping)) {
        switch ($image_style_mapping['image_mapping_type']) {
          case 'image_style':
            $image_styles[] = $image_style_mapping['image_mapping'];
            break;

          case 'sizes':
            $image_styles = array_merge($image_styles$image_style_mapping['image_mapping']['sizes_image_styles']);
            break;
        }
// Expand the details if "do not use this breakpoint" was not selected.         if ($form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type']['#default_value'] != '_none') {
          $form['keyed_styles'][$breakpoint_id][$multiplier]['#open'] = TRUE;
        }
      }
    }

    $form['fallback_image_style'] = [
      '#title' => $this->t('Fallback image style'),
      '#type' => 'select',
      '#default_value' => $responsive_image_style->getFallbackImageStyle(),
      '#options' => $image_styles,
      '#required' => TRUE,
      '#description' => $this->t('Select the image style you wish to use as the style when a browser does not support responsive images.'),
    ];

    $form['#tree'] = TRUE;

    return parent::form($form$form_state);
  }

  /** * Get the form for mapping breakpoints to image styles. */
Home | Imprint | This part of the site doesn't use cookies.