summaryrefslogtreecommitdiffstats
path: root/core/modules/responsive_image/responsive_image.module
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/responsive_image/responsive_image.module')
-rw-r--r--core/modules/responsive_image/responsive_image.module28
1 files changed, 14 insertions, 14 deletions
diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module
index 63f25e6..d8985c9 100644
--- a/core/modules/responsive_image/responsive_image.module
+++ b/core/modules/responsive_image/responsive_image.module
@@ -5,7 +5,6 @@
* Responsive image display formatter for image fields.
*/
-use Drupal\breakpoint\Entity\Breakpoint;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Routing\RouteMatchInterface;
use \Drupal\Core\Template\Attribute;
@@ -90,7 +89,7 @@ function responsive_image_theme() {
'alt' => '',
'title' => NULL,
'attributes' => array(),
- 'breakpoints' => array(),
+ 'mapping_id' => array(),
),
),
'responsive_image_formatter' => array(
@@ -98,7 +97,7 @@ function responsive_image_theme() {
'item' => NULL,
'path' => NULL,
'image_style' => NULL,
- 'breakpoints' => array(),
+ 'mapping_id' => array(),
),
),
'responsive_image_source' => array(
@@ -120,13 +119,13 @@ function responsive_image_theme() {
* - item: An ImageItem object.
* - image_style: An optional image style.
* - path: An optional array containing the link 'path' and link 'options'.
- * - breakpoints: An array containing breakpoints.
+ * - mapping_id: The ID of the responsive image mapping.
*
* @ingroup themeable
*/
function theme_responsive_image_formatter($variables) {
$item = $variables['item'];
- if (!isset($variables['breakpoints']) || empty($variables['breakpoints'])) {
+ if (!isset($variables['mapping_id']) || empty($variables['mapping_id'])) {
$image_formatter = array(
'#theme' => 'image_formatter',
'#item' => $item,
@@ -141,7 +140,7 @@ function theme_responsive_image_formatter($variables) {
'#width' => $item->width,
'#height' => $item->height,
'#style_name' => $variables['image_style'],
- '#breakpoints' => $variables['breakpoints'],
+ '#mapping_id' => $variables['mapping_id'],
);
if (isset($item->uri)) {
$responsive_image['#uri'] = $item->uri;
@@ -178,7 +177,7 @@ function theme_responsive_image_formatter($variables) {
* - title: The title text is displayed when the image is hovered in some
* popular browsers.
* - style_name: The name of the style to be used as a fallback image.
- * - breakpoints: An array containing breakpoints.
+ * - mapping_id: The ID of the responsive image mapping.
*
* @ingroup themeable
*/
@@ -202,11 +201,12 @@ function theme_responsive_image($variables) {
'src' => _responsive_image_image_style_url($variables['style_name'], $variables['uri']),
'dimensions' => responsive_image_get_image_dimensions($variables),
);
-
+ $responsive_image_mapping = entity_load('responsive_image_mapping', $variables['mapping_id']);
// All breakpoints and multipliers.
- foreach ($variables['breakpoints'] as $breakpoint_name => $multipliers) {
- $breakpoint = Breakpoint::load($breakpoint_name);
- if ($breakpoint) {
+ $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup($responsive_image_mapping->getBreakpointGroup());
+ foreach ($responsive_image_mapping->getKeyedMappings() as $breakpoint_id => $multipliers) {
+ if (isset($breakpoints[$breakpoint_id])) {
+ $breakpoint = $breakpoints[$breakpoint_id];
$new_sources = array();
foreach ($multipliers as $multiplier => $image_style) {
$new_source = $variables;
@@ -220,7 +220,7 @@ function theme_responsive_image($variables) {
$sources[] = array(
'src' => _responsive_image_image_style_url($new_sources[0]['style_name'], $new_sources[0]['uri']),
'dimensions' => responsive_image_get_image_dimensions($new_sources[0]),
- 'media' => $breakpoint->mediaQuery,
+ 'media' => $breakpoint->getMediaQuery(),
);
}
else {
@@ -232,7 +232,7 @@ function theme_responsive_image($variables) {
$sources[] = array(
'srcset' => implode(', ', $srcset),
'dimensions' => responsive_image_get_image_dimensions($new_sources[0]),
- 'media' => $breakpoint->mediaQuery,
+ 'media' => $breakpoint->getMediaQuery(),
);
}
}
@@ -266,7 +266,7 @@ function theme_responsive_image($variables) {
/**
* Returns HTML for a source tag.
*
- * @param type $variables
+ * @param array $variables
* An associative array containing:
* - media: The media query to use.
* - srcset: The srcset containing the the path of the image file or a full