[html] clean data attributes (#3782)

Some feed readers had difficulties with attributes containing html tags
This commit is contained in:
ORelio 2023-10-24 19:57:25 +02:00 committed by GitHub
parent d4e4c3e89a
commit cee25d862d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -269,7 +269,15 @@ function convertLazyLoading($dom)
} else {
continue; // Proceed to next element without removing attributes
}
// Remove attributes that may be processed by the client (data-* are not)
// Remove data attributes, no longer necessary
foreach ($img->getAllAttributes() as $attr => $val) {
if (str_starts_with($attr, 'data-')) {
$img->removeAttribute($attr);
}
}
// Remove other attributes that may be processed by the client
foreach (['loading', 'decoding', 'srcset'] as $attr) {
if ($img->hasAttribute($attr)) {
$img->removeAttribute($attr);