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