Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By attiks on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Description:
It is now easy to output a responsive image from code
A picture tag can now be rendered by using
$content['hero_image_responsive'] = array(
'#type' => 'responsive_image',
'#uri' => 'public://hero-image.png',
'#attributes' => array(
'alt' => t('Hero image'),
'title' => t('Hero image title'),
),
'#responsive_image_style_id' => 'hero',
);
Impacts:
Site builders, administrators, editors
Module developers
Themers