function ResponsiveImageStyle::isEmptyImageStyleMapping

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

Overrides ResponsiveImageStyleInterface::isEmptyImageStyleMapping

1 call to ResponsiveImageStyle::isEmptyImageStyleMapping()
ResponsiveImageStyle::getKeyedImageStyleMappings in core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php
Returns the mappings of breakpoint ID and multiplier to image style.

File

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

Class

ResponsiveImageStyle
Defines the responsive image style entity.

Namespace

Drupal\responsive_image\Entity

Code

public static function isEmptyImageStyleMapping(array $image_style_mapping) {
    if (!empty($image_style_mapping)) {
        switch ($image_style_mapping['image_mapping_type']) {
            case 'sizes':
                // The image style mapping must have a sizes attribute defined and one
                // or more image styles selected.
                if ($image_style_mapping['image_mapping']['sizes'] && $image_style_mapping['image_mapping']['sizes_image_styles']) {
                    return FALSE;
                }
                break;
            case 'image_style':
                // The image style mapping must have an image style selected.
                if ($image_style_mapping['image_mapping']) {
                    return FALSE;
                }
                break;
        }
    }
    return TRUE;
}

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