Closed andressoop closed 3 years ago
Any updates on this?
Imagify replaces img tags inside existing picture tags
we can remove all picture
tags from the page before search for img
tags with regex
add new function to remove picture tags
private function remove_picture_tags( string $html ): string {
$replace = preg_replace( '#<picture[^>]*>.*?<\/picture\s*>#mis', '', $html );
if ( null === $replace ) {
return $html;
}
return $replace;
}
in process_content function, we need to removefirst
$html_no_picture_tags= $this->remove_picture_tags($content);
[S]
@iCaspar @mostafa-hisham It's the year 2023, and this is still an issue. I could decide to create another issue for this, but since I saw this issue perfectly describes the bug - I have decided to drop a comment. In summary, Imagify removes the className in the <img>
tag and adds it to the <picture>
tag.
For example: <img class="akfdev" src="https://random.com/media/akfdev.png" alt"Francis">
is rendered as:
<picture class="akfdev">
<img src="https://random.com/media/akfdev.png" alt"Francis">
</picture>
Describe the bug When webp images display option with picture tags is used from the settings and theme already has picture tags present, then Imagify replaces img tags inside existing picture tags resulting in nested
Expected behavior Imagify should ignore already existing picture tags with webp images.
Screenshots
Backlog Grooming (for WP Media dev team use only)