ResponsiveImageStyle::getImageStyleIds

public ResponsiveImageStyle::getImageStyleIds()

Gets all the image styles IDs involved in the responsive image mapping.

Return value

string[]

Overrides ResponsiveImageStyleInterface::getImageStyleIds

File

core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php, line 250

Class

ResponsiveImageStyle
Defines the responsive image style entity.

Namespace

Drupal\responsive_image\Entity

Code

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;
      }
    }
  }
  return array_values(array_filter(array_unique($image_styles)));
}
doc_Drupal
2016-10-29 09:38:00
Comments
Leave a Comment

Please login to continue.