ResponsiveImageStyle::isEmptyImageStyleMapping

public static ResponsiveImageStyle::isEmptyImageStyleMapping(array $image_style_mapping)

Checks if there is at least one image style mapping defined.

Parameters

array $image_style_mapping: The image style mapping.

Return value

bool Whether the image style mapping is empty.

Overrides ResponsiveImageStyleInterface::isEmptyImageStyleMapping

File

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

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;
}
doc_Drupal
2016-10-29 09:38:01
Comments
Leave a Comment

Please login to continue.