Skip to content

Commit

Permalink
Merge branch '5.0/lazy-load-images-2' into 5.0-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Nov 13, 2024
2 parents c051f7b + d2a9abe commit 3622dfc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion etc/cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ requires 'HTML::Gumbo';
requires 'HTML::Mason', '>= 1.43';
requires 'HTML::Mason::PSGIHandler', '>= 0.52';
requires 'HTML::Quoted';
requires 'HTML::RewriteAttributes', '>= 0.05';
requires 'HTML::RewriteAttributes', '>= 0.06';
requires 'HTML::Scrubber', '>= 0.08';
requires 'HTTP::Message', '>= 6.07';
requires 'IPC::Run3';
Expand Down
11 changes: 8 additions & 3 deletions lib/RT/Interface/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1986,9 +1986,14 @@ sub RewriteInlineImages {
$$content = HTML::RewriteAttributes::Resources->rewrite($$content, sub {
my $cid = shift;
my %meta = @_;
return $cid unless lc $meta{tag} eq 'img'
and lc $meta{attr} eq 'src'
and $cid =~ s/^cid://i;
return $cid unless lc $meta{tag} eq 'img';

if ( !$meta{attrs}{loading} ) {
$meta{attrs}{loading} = 'lazy';
push @{ $meta{attr_list} }, 'loading';
}

return $cid unless lc $meta{attr} eq 'src' && $cid =~ s/^cid://i;

for my $attach (@{$args{Related}}) {
if (($attach->GetHeader('Content-ID') || '') =~ /^(<)?\Q$cid\E(?(1)>)$/) {
Expand Down
2 changes: 1 addition & 1 deletion share/html/Elements/ShowTransactionAttachments
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ my $render_attachment = sub {
. $m->interp->apply_escapes( $filename, 'u', 'h' );

$m->out(
qq{<img alt="$efilename" title="$efilename" src="$url" />}
qq{<img alt="$efilename" title="$efilename" src="$url" loading="lazy" />}
);
}
elsif ( $message->ContentLength && $message->ContentLength > 0 ) {
Expand Down

0 comments on commit 3622dfc

Please sign in to comment.