diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index b4731f9..ea99ca1 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -376,7 +376,7 @@ function responsive_image_build_source_attributes(ImageInterface $image, array $ if (is_null($dimensions['width'])) { throw new \LogicException(String::format('Could not determine image width for @file using image style with ID: @image_style_name. This image style can not be used for a responsive image style mapping using the \'sizes\' attribute.', array('@file' => $image->getSource(), '@image_style_name' => $image_style_name))); } - $srcset[floatval($dimensions['width'])] = file_create_url(_responsive_image_image_style_url($image_style_name, $image->getSource())) . ' ' . $dimensions['width'] . 'w'; + $srcset[(string) $dimensions['width']] = file_create_url(_responsive_image_image_style_url($image_style_name, $image->getSource())) . ' ' . $dimensions['width'] . 'w'; $sizes = array_merge(explode(',', $image_style_mapping['image_mapping']['sizes']), $sizes); } break; @@ -386,7 +386,7 @@ function responsive_image_build_source_attributes(ImageInterface $image, array $ $derivative_mime_type = responsive_image_get_mime_type($image_style_mapping['image_mapping'], $extension); $derivative_mime_types[] = $derivative_mime_type; // Add the image source with its multiplier. - $srcset[floatval(Unicode::substr($multiplier, 0, -1))] = file_create_url(_responsive_image_image_style_url($image_style_mapping['image_mapping'], $image->getSource())) . ' ' . $multiplier; + $srcset[Unicode::substr($multiplier, 0, -1)] = file_create_url(_responsive_image_image_style_url($image_style_mapping['image_mapping'], $image->getSource())) . ' ' . $multiplier; break; } } diff --git a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php index c59c7ee..42f4c47 100644 --- a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php +++ b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php @@ -296,6 +296,9 @@ public function testResponsiveImageFieldFormattersLinkToNode() { /** * Tests responsive image formatters linked to the file or node. + * + * @param string $link_type + * The link type to test. Either 'file' or 'content'. */ private function assertResponsiveImageFieldFormattersLink($link_type) { $field_name = Unicode::strtolower($this->randomMachineName());