Deprecated function: Implicit conversion from float 1234.5678 to int loses precision in Drupal\image_sizes\ImageSizesService::getStyles()

Created on 1 February 2024, 5 months ago

Problem/Motivation

This is a follow up to πŸ“Œ Improve image style width detection and avoid obsolete image derivatives Fixed , whose changes do not handle float width values very good when checking the $styles array with $dimensions['width'] and $width as array key. Depending on your image style configuration and its resulting transformations, $style->transformDimensions() may return float values for width and height instead of integers.

Steps to reproduce

  • Create an image style that does some scaling (e.g. height only while preserving aspect ratio) which might result in float values for the resulting width
  • Use the previously created image style in an image sizes preset
  • Deprecated function: Implicit conversion from float ... to int... notice will occur on pages that output images with that image sizes preset (NOTE: But only if the image style calculations will result in a float value for width)

Proposed resolution

  • Ensure that $dimensions['width'] and $width is always a string value, when used as array key identifier

Remaining tasks

  • Create a path or issue fork with MR to solve this issue

User interface changes

n/a

API changes

n/a

Data model changes

n/a

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany hctom

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024