- Issue created by @johnalbin
 
The responsive image module is designed to usually output a picture element. Except when (from template_preprocess_responsive_image()):
// There is only one source tag with an empty media attribute. This means // we can output an image tag with the srcset attribute instead of a // picture tag. $variables['output_image_tag'] = TRUE;
The webp module will duplicate any source tag that is not already a webp image and then prepend those new sources to the sources list and force the responsive image module to use the picture element since there will always be 2 or more sources.
Smartly, if a source in a responsive image style is already converted to webp (with Drupal Core's "Convert" image filter), then webp will skip that source and only duplicate sources that are not webp.
However, there is a bug in webp module if there is only one source in the responsive image style and its already a webp image because the webp module won't actually add any additional source tags, but the webp module will still turn off the output_image_tag twig variable.
The webp module's code comment is wrong here:
// Never output a single image tag, because // we will always have at least two sources.
because you won't have two sources if there is only one original source and it's already a webp image.
Under these specific circumstances, the webp module will force the responsive image template to use a picture element when it shouldn't.
picture element and only contains 1 source element.picture element, but instead using a img element with srcset and sizes attributes.
Check if webp actually needs to add sources to the list before setting the output_image_tag variable.
Active
1.0
Code