Skip to content

Commit

Permalink
Set lazy loading for iframe.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Apr 8, 2024
1 parent ae7af69 commit 2857ce7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion application/src/Media/Renderer/Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function render(PhpRenderer $view, MediaRepresentation $media,
}
$url->setQuery($query);
$embed = sprintf(
'<iframe width="%s" height="%s" src="%s" frameborder="0"%s></iframe>',
'<iframe loading="lazy" width="%s" height="%s" src="%s" frameborder="0"%s></iframe>',
$view->escapeHtml($options['width']),
$view->escapeHtml($options['height']),
$view->escapeHtml($url),
Expand Down
2 changes: 1 addition & 1 deletion application/src/View/Helper/IiifViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public function __invoke(array $query, array $options = [])
$width = $options['width'] ?? '100%';
$height = $options['height'] ?? '700px';
$src = $view->url('iiif-viewer', [], ['force_canonical' => true, 'query' => $query]);
return sprintf('<iframe style="width: %s; height: %s;" src="%s"></iframe>', $width, $height, $view->escapeHtml($src));
return sprintf('<iframe loading="lazy" style="width: %s; height: %s;" src="%s"></iframe>', $width, $height, $view->escapeHtml($src));
}
}

0 comments on commit 2857ce7

Please sign in to comment.