Change record status: 
Project: 
Introduced in branch: 
11.4.x
Introduced in version: 
11.4.0
Description: 

The #url variable in the responsive image theme element is now a Drupal\Core\Urlobject, which allows for manipulating URL options. Previously the variable was a string.

This variable is available as url in the response-image-formatter.html.twig template.

Before

  #[Hook('preprocess_responsive_image_formatter')]
  public function preprocessResponsiveImageFormatter(array &$variables): void {
    $url = $variables['#url'];
    // E.g., $url === 'https://drupal.org'.
  }

After

  #[Hook('preprocess_responsive_image_formatter')]
  public function preprocessResponsiveImageFormatter(array &$variables): void {
    $url = $variables['#url'];
    // E.g., $url->toString() === 'https://drupal.org'.
  }
}

Impact on themes and modules

Any theme or module that implements a preprocess_response_image_formatter hook that uses the #url property will need to be updated to account for the new variable type.

Use in Twig templates is generally not affected, as {{ url }} outputs the URL string as before.

Impacts: 
Module developers
Themers