trim(): Passing null to parameter #1 ($string) of type string is deprecated in _responsive_image_build_source_attributes()

Created on 16 March 2022, over 2 years ago
Updated 5 March 2024, 9 months ago
Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in _responsive_image_build_source_attributes() (line 414 of core/modules/responsive_image/responsive_image.module).
·         _responsive_image_build_source_attributes(Array, Object, Array) (Line: 173)
·         template_preprocess_responsive_image(Array, 'responsive_image', Array) (Line: 287)
·         Drupal\Core\Theme\ThemeManager->render('responsive_image', Array) (Line: 422)
·         Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
·         Drupal\Core\Render\Renderer->render(Array) (Line: 479)
·         Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 50)
·         __TwigTemplate_b0521e86aaa2ccb2263d138013ee9ad9->doDisplay(Array, Array) (Line: 405)
·         Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
·         Twig\Template->display(Array) (Line: 390)
·         Twig\Template->render(Array) (Line: 55)
·         twig_render_template('core/themes/stable/templates/field/responsive-image-formatter.html.twig', Array) (Line: 384)
·         Drupal\Core\Theme\ThemeManager->render('responsive_image_formatter', Array) (Line: 422)
·         Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
·         Drupal\Core\Render\Renderer->render(Array) (Line: 479)
·         Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 44)
·         __TwigTemplate_7f89780e69a1d2ac98482da07a3293ff->doDisplay(Array, Array) (Line: 405)
·         Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
·         Twig\Template->display(Array) (Line: 390)
·         Twig\Template->render(Array) (Line: 55)
·         twig_render_template('themes/custom/klesia_extranet/templates/field/field.html.twig', Array) (Line: 384)
·         Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 422)
·         Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
·         Drupal\Core\Render\Renderer->render(Array) (Line: 479)
·         Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 44)
·         __TwigTemplate_f09ca4698c8f32f6a8ab2822b02b331c->doDisplay(Array, Array) (Line: 405)
·         Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
·         Twig\Template->display(Array) (Line: 390)
·         Twig\Template->render(Array) (Line: 55)
·         twig_render_template('themes/custom/klesia_extranet/templates/user/user.html.twig', Array) (Line: 384)
·         Drupal\Core\Theme\ThemeManager->render('user', Array) (Line: 422)
·         Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
·         Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
·         Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
·         Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
·         Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
·         Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
·         Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
·         call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
·         Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
·         Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
·         Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
·         Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
·         Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 48)
·         Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
·         Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
·         Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
·         Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in _responsive_image_build_source_attributes() (line 414 of core/modules/responsive_image/responsive_image.module).

Workaround:
If your theme.breakpoints.yml file has an empty value for a mediaQuery, just add empty quotes and this warning will go away.

So this:

theme.xsmall:
  label: xsmall
  mediaQuery:
  weight: 0
  multipliers:
    - 1x
    - 2x

Changed to this:

theme.xsmall:
  label: xsmall
  mediaQuery: ""
  weight: 0
  multipliers:
    - 1x
    - 2x
🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Responsive image 

Last updated 1 day ago

Created by

🇫🇷France mddia

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024