yireo / Yireo_Webp2

Magento 2 module to add WebP support to Magento 2
Open Software License 3.0
194 stars 54 forks source link

How to prevent <img> to <picture> set conversion? #133

Open MagePsycho opened 1 year ago

MagePsycho commented 1 year ago

I have recently noticed one issue while using the <img/> tag in the JS variable. For example:

<script>
var imgElement = '<img src="..." />';
</script>

As Yireo_Webp2 extension converts <img/> element to <picture>...</picture> set, it throws the JS error as the output looks like

var imgElement = '<picture>
  <source type="image/webp" srcset="...">
  <source type="image/png" srcset="...">
  <img src="..." />
</picture>'

Is there a way to stop the <img/> element from the conversion

tommypyatt commented 1 year ago

It's ugly, but here's a suggestion:

var imgElement = '<__TAGNAME__ src="..." />'.replace('__TAGNAME__', 'img')
jissereitsma commented 1 year ago

Could you see if this issue persists after upgrading Yireo NextGenImages to version 0.3.14?