function ResponsiveImageStyle::getImageStyleIds

Same name in other branches
  1. 9 core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php \Drupal\responsive_image\Entity\ResponsiveImageStyle::getImageStyleIds()
  2. 10 core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php \Drupal\responsive_image\Entity\ResponsiveImageStyle::getImageStyleIds()
  3. 11.x core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php \Drupal\responsive_image\Entity\ResponsiveImageStyle::getImageStyleIds()

Overrides ResponsiveImageStyleInterface::getImageStyleIds

1 call to ResponsiveImageStyle::getImageStyleIds()
ResponsiveImageStyle::calculateDependencies in core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php
Calculates dependencies and stores them in the dependency property.

File

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

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)));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.