Skip to content

Commit

Permalink
[html] clean data attributes (#3782)
Browse files Browse the repository at this point in the history
Some feed readers had difficulties with attributes containing html tags
  • Loading branch information
ORelio authored Oct 24, 2023
1 parent d4e4c3e commit cee25d8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cee25d8

Please sign in to comment.