3 namespace Drupal\responsive_image;
5 use Drupal\Core\Config\Entity\ConfigEntityInterface;
8 * Provides an interface defining a responsive_image mapping entity.
10 interface ResponsiveImageStyleInterface extends ConfigEntityInterface {
13 * The machine name for the empty image breakpoint image style option.
15 const EMPTY_IMAGE = '_empty image_';
18 * The machine name for the original image breakpoint image style option.
20 const ORIGINAL_IMAGE = '_original image_';
23 * Checks if there is at least one mapping defined.
26 * Whether the entity has any image style mappings.
28 public function hasImageStyleMappings();
31 * Returns the mappings of breakpoint ID and multiplier to image style.
34 * The image style mappings. Keyed by breakpoint ID then multiplier.
35 * The value is the image style mapping array with following keys:
36 * - image_mapping_type: Either 'image_style' or 'sizes'.
38 * - If image_mapping_type is 'image_style', the image style ID.
39 * - If image_mapping_type is 'sizes', an array with following keys:
40 * - sizes: The value for the 'sizes' attribute.
41 * - sizes_image_styles: The image styles to use for the 'srcset'
43 * - breakpoint_id: The breakpoint ID for this mapping.
44 * - multiplier: The multiplier for this mapping.
46 public function getKeyedImageStyleMappings();
49 * Returns the image style mappings for the responsive image style.
52 * An array of image style mappings. Each image style mapping array
53 * contains the following keys:
56 * - image_mapping_type
59 public function getImageStyleMappings();
62 * Sets the breakpoint group for the responsive image style.
64 * @param string $breakpoint_group
65 * The responsive image style breakpoint group.
69 public function setBreakpointGroup($breakpoint_group);
72 * Returns the breakpoint group for the responsive image style.
75 * The breakpoint group.
77 public function getBreakpointGroup();
80 * Sets the fallback image style for the responsive image style.
82 * @param string $fallback_image_style
83 * The fallback image style ID.
87 public function setFallbackImageStyle($fallback_image_style);
90 * Returns the fallback image style ID for the responsive image style.
93 * The fallback image style ID.
95 public function getFallbackImageStyle();
98 * Gets the image style mapping for a breakpoint ID and multiplier.
100 * @param string $breakpoint_id
102 * @param string $multiplier
106 * The image style mapping. NULL if the mapping does not exist.
107 * The image style mapping has following keys:
108 * - image_mapping_type: Either 'image_style' or 'sizes'.
110 * - If image_mapping_type is 'image_style', the image style ID.
111 * - If image_mapping_type is 'sizes', an array with following keys:
112 * - sizes: The value for the 'sizes' attribute.
113 * - sizes_image_styles: The image styles to use for the 'srcset'
115 * - breakpoint_id: The breakpoint ID for this image style mapping.
116 * - multiplier: The multiplier for this image style mapping.
118 public function getImageStyleMapping($breakpoint_id, $multiplier);
121 * Checks if there is at least one image style mapping defined.
123 * @param array $image_style_mapping
124 * The image style mapping.
127 * Whether the image style mapping is empty.
129 public static function isEmptyImageStyleMapping(array $image_style_mapping);
132 * Adds a image style mapping to the responsive image configuration entity.
134 * @param string $breakpoint_id
136 * @param string $multiplier
138 * @param array $image_style_mapping
139 * The mapping image style mapping.
143 public function addImageStyleMapping($breakpoint_id, $multiplier, array $image_style_mapping);
146 * Removes all image style mappings from the responsive image style.
150 public function removeImageStyleMappings();
153 * Gets all the image styles IDs involved in the responsive image mapping.
157 public function getImageStyleIds();