Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\responsive_image;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Provides an interface defining a responsive_image mapping entity.
|
Chris@0
|
9 */
|
Chris@0
|
10 interface ResponsiveImageStyleInterface extends ConfigEntityInterface {
|
Chris@0
|
11
|
Chris@0
|
12 /**
|
Chris@0
|
13 * The machine name for the empty image breakpoint image style option.
|
Chris@0
|
14 */
|
Chris@0
|
15 const EMPTY_IMAGE = '_empty image_';
|
Chris@0
|
16
|
Chris@0
|
17 /**
|
Chris@0
|
18 * The machine name for the original image breakpoint image style option.
|
Chris@0
|
19 */
|
Chris@0
|
20 const ORIGINAL_IMAGE = '_original image_';
|
Chris@0
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Checks if there is at least one mapping defined.
|
Chris@0
|
24 *
|
Chris@0
|
25 * @return bool
|
Chris@0
|
26 * Whether the entity has any image style mappings.
|
Chris@0
|
27 */
|
Chris@0
|
28 public function hasImageStyleMappings();
|
Chris@0
|
29
|
Chris@0
|
30 /**
|
Chris@0
|
31 * Returns the mappings of breakpoint ID and multiplier to image style.
|
Chris@0
|
32 *
|
Chris@0
|
33 * @return array[]
|
Chris@0
|
34 * The image style mappings. Keyed by breakpoint ID then multiplier.
|
Chris@0
|
35 * The value is the image style mapping array with following keys:
|
Chris@0
|
36 * - image_mapping_type: Either 'image_style' or 'sizes'.
|
Chris@0
|
37 * - image_mapping:
|
Chris@0
|
38 * - If image_mapping_type is 'image_style', the image style ID.
|
Chris@0
|
39 * - If image_mapping_type is 'sizes', an array with following keys:
|
Chris@0
|
40 * - sizes: The value for the 'sizes' attribute.
|
Chris@0
|
41 * - sizes_image_styles: The image styles to use for the 'srcset'
|
Chris@0
|
42 * attribute.
|
Chris@0
|
43 * - breakpoint_id: The breakpoint ID for this mapping.
|
Chris@0
|
44 * - multiplier: The multiplier for this mapping.
|
Chris@0
|
45 */
|
Chris@0
|
46 public function getKeyedImageStyleMappings();
|
Chris@0
|
47
|
Chris@0
|
48 /**
|
Chris@0
|
49 * Returns the image style mappings for the responsive image style.
|
Chris@0
|
50 *
|
Chris@0
|
51 * @return array[]
|
Chris@0
|
52 * An array of image style mappings. Each image style mapping array
|
Chris@0
|
53 * contains the following keys:
|
Chris@0
|
54 * - breakpoint_id
|
Chris@0
|
55 * - multiplier
|
Chris@0
|
56 * - image_mapping_type
|
Chris@0
|
57 * - image_mapping
|
Chris@0
|
58 */
|
Chris@0
|
59 public function getImageStyleMappings();
|
Chris@0
|
60
|
Chris@0
|
61 /**
|
Chris@0
|
62 * Sets the breakpoint group for the responsive image style.
|
Chris@0
|
63 *
|
Chris@0
|
64 * @param string $breakpoint_group
|
Chris@0
|
65 * The responsive image style breakpoint group.
|
Chris@0
|
66 *
|
Chris@0
|
67 * @return $this
|
Chris@0
|
68 */
|
Chris@0
|
69 public function setBreakpointGroup($breakpoint_group);
|
Chris@0
|
70
|
Chris@0
|
71 /**
|
Chris@0
|
72 * Returns the breakpoint group for the responsive image style.
|
Chris@0
|
73 *
|
Chris@0
|
74 * @return string
|
Chris@0
|
75 * The breakpoint group.
|
Chris@0
|
76 */
|
Chris@0
|
77 public function getBreakpointGroup();
|
Chris@0
|
78
|
Chris@0
|
79 /**
|
Chris@0
|
80 * Sets the fallback image style for the responsive image style.
|
Chris@0
|
81 *
|
Chris@0
|
82 * @param string $fallback_image_style
|
Chris@0
|
83 * The fallback image style ID.
|
Chris@0
|
84 *
|
Chris@0
|
85 * @return $this
|
Chris@0
|
86 */
|
Chris@0
|
87 public function setFallbackImageStyle($fallback_image_style);
|
Chris@0
|
88
|
Chris@0
|
89 /**
|
Chris@0
|
90 * Returns the fallback image style ID for the responsive image style.
|
Chris@0
|
91 *
|
Chris@0
|
92 * @return string
|
Chris@0
|
93 * The fallback image style ID.
|
Chris@0
|
94 */
|
Chris@0
|
95 public function getFallbackImageStyle();
|
Chris@0
|
96
|
Chris@0
|
97 /**
|
Chris@0
|
98 * Gets the image style mapping for a breakpoint ID and multiplier.
|
Chris@0
|
99 *
|
Chris@0
|
100 * @param string $breakpoint_id
|
Chris@0
|
101 * The breakpoint ID.
|
Chris@0
|
102 * @param string $multiplier
|
Chris@0
|
103 * The multiplier.
|
Chris@0
|
104 *
|
Chris@0
|
105 * @return array|null
|
Chris@0
|
106 * The image style mapping. NULL if the mapping does not exist.
|
Chris@0
|
107 * The image style mapping has following keys:
|
Chris@0
|
108 * - image_mapping_type: Either 'image_style' or 'sizes'.
|
Chris@0
|
109 * - image_mapping:
|
Chris@0
|
110 * - If image_mapping_type is 'image_style', the image style ID.
|
Chris@0
|
111 * - If image_mapping_type is 'sizes', an array with following keys:
|
Chris@0
|
112 * - sizes: The value for the 'sizes' attribute.
|
Chris@0
|
113 * - sizes_image_styles: The image styles to use for the 'srcset'
|
Chris@0
|
114 * attribute.
|
Chris@0
|
115 * - breakpoint_id: The breakpoint ID for this image style mapping.
|
Chris@0
|
116 * - multiplier: The multiplier for this image style mapping.
|
Chris@0
|
117 */
|
Chris@0
|
118 public function getImageStyleMapping($breakpoint_id, $multiplier);
|
Chris@0
|
119
|
Chris@0
|
120 /**
|
Chris@0
|
121 * Checks if there is at least one image style mapping defined.
|
Chris@0
|
122 *
|
Chris@0
|
123 * @param array $image_style_mapping
|
Chris@0
|
124 * The image style mapping.
|
Chris@0
|
125 *
|
Chris@0
|
126 * @return bool
|
Chris@0
|
127 * Whether the image style mapping is empty.
|
Chris@0
|
128 */
|
Chris@0
|
129 public static function isEmptyImageStyleMapping(array $image_style_mapping);
|
Chris@0
|
130
|
Chris@0
|
131 /**
|
Chris@0
|
132 * Adds a image style mapping to the responsive image configuration entity.
|
Chris@0
|
133 *
|
Chris@0
|
134 * @param string $breakpoint_id
|
Chris@0
|
135 * The breakpoint ID.
|
Chris@0
|
136 * @param string $multiplier
|
Chris@0
|
137 * The multiplier.
|
Chris@0
|
138 * @param array $image_style_mapping
|
Chris@0
|
139 * The mapping image style mapping.
|
Chris@0
|
140 *
|
Chris@0
|
141 * @return $this
|
Chris@0
|
142 */
|
Chris@0
|
143 public function addImageStyleMapping($breakpoint_id, $multiplier, array $image_style_mapping);
|
Chris@0
|
144
|
Chris@0
|
145 /**
|
Chris@0
|
146 * Removes all image style mappings from the responsive image style.
|
Chris@0
|
147 *
|
Chris@0
|
148 * @return $this
|
Chris@0
|
149 */
|
Chris@0
|
150 public function removeImageStyleMappings();
|
Chris@0
|
151
|
Chris@0
|
152 /**
|
Chris@0
|
153 * Gets all the image styles IDs involved in the responsive image mapping.
|
Chris@0
|
154 *
|
Chris@0
|
155 * @return string[]
|
Chris@0
|
156 */
|
Chris@0
|
157 public function getImageStyleIds();
|
Chris@0
|
158
|
Chris@0
|
159 }
|