Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/responsive_image/responsive_image.module @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children | 12f9dff5fda9 |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
5 * Responsive image display formatter for image fields. | 5 * Responsive image display formatter for image fields. |
6 */ | 6 */ |
7 | 7 |
8 use Drupal\Core\Template\Attribute; | 8 use Drupal\Core\Template\Attribute; |
9 use Drupal\Core\Logger\RfcLogLevel; | 9 use Drupal\Core\Logger\RfcLogLevel; |
10 use Drupal\Component\Utility\Unicode; | |
11 use Drupal\Core\Routing\RouteMatchInterface; | 10 use Drupal\Core\Routing\RouteMatchInterface; |
12 use Drupal\image\Entity\ImageStyle; | 11 use Drupal\image\Entity\ImageStyle; |
13 use Drupal\responsive_image\Entity\ResponsiveImageStyle; | 12 use Drupal\responsive_image\Entity\ResponsiveImageStyle; |
14 use Drupal\Core\Image\ImageInterface; | 13 use Drupal\Core\Image\ImageInterface; |
15 use Drupal\breakpoint\BreakpointInterface; | 14 use Drupal\breakpoint\BreakpointInterface; |
125 ]; | 124 ]; |
126 } | 125 } |
127 $item = $variables['item']; | 126 $item = $variables['item']; |
128 $attributes = []; | 127 $attributes = []; |
129 // Do not output an empty 'title' attribute. | 128 // Do not output an empty 'title' attribute. |
130 if (Unicode::strlen($item->title) != 0) { | 129 if (mb_strlen($item->title) != 0) { |
131 $attributes['title'] = $item->title; | 130 $attributes['title'] = $item->title; |
132 } | 131 } |
133 $attributes['alt'] = $item->alt; | 132 $attributes['alt'] = $item->alt; |
134 // Need to check that item_attributes has a value since it can be NULL. | 133 // Need to check that item_attributes has a value since it can be NULL. |
135 if ($variables['item_attributes']) { | 134 if ($variables['item_attributes']) { |
447 // Add the image source with its multiplier. Use the multiplier as key | 446 // Add the image source with its multiplier. Use the multiplier as key |
448 // so we can sort the array later on. Multipliers within a srcset should | 447 // so we can sort the array later on. Multipliers within a srcset should |
449 // be sorted from small to large, since the first matching source will | 448 // be sorted from small to large, since the first matching source will |
450 // be used. We multiply it by 100 so multipliers with up to two decimals | 449 // be used. We multiply it by 100 so multipliers with up to two decimals |
451 // can be used. | 450 // can be used. |
452 $srcset[intval(Unicode::substr($multiplier, 0, -1) * 100)] = _responsive_image_image_style_url($image_style_mapping['image_mapping'], $variables['uri']) . ' ' . $multiplier; | 451 $srcset[intval(mb_substr($multiplier, 0, -1) * 100)] = _responsive_image_image_style_url($image_style_mapping['image_mapping'], $variables['uri']) . ' ' . $multiplier; |
453 break; | 452 break; |
454 } | 453 } |
455 } | 454 } |
456 // Sort the srcset from small to large image width or multiplier. | 455 // Sort the srcset from small to large image width or multiplier. |
457 ksort($srcset); | 456 ksort($srcset); |