Skip to content

Commit

Permalink
Limit responsive image URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Sep 13, 2024
1 parent 21e084c commit a9f2a5a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dist/responsive_images.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ function intrinsicOrExtrinsicSizing( computedStyles ) {
function getImgData( img ) {

const imgData = imgFeatures( img );
imgData.url = img.currentSrc || img.src;
// Limit URLs to 200 chars so data URLs don't take up huge amounts of space.
imgData.url =
(img.currentSrc || img.src).length > 200 ?
(img.currentSrc || img.src).slice(0, 199) + '…' :
(img.currentSrc || img.src);
imgData.totalCandidates = totalNumberOfCandidates( img );

if (imgData.hasHeight) {
Expand Down Expand Up @@ -358,7 +362,8 @@ function getImgData( img ) {
!isFromSource &&
!( imgData.srcsetHasWDescriptors ) ) {
srcsetCandidates.push( {
url: img.getAttribute( 'src' )
// Limit URLs to 200 chars so data URLs don't take up huge amounts of space.
url: img.getAttribute( 'src' ).length > 200 ? img.getAttribute( 'src' ).slice(0, 199) + '…' : img.getAttribute( 'src' )
} )
}

Expand Down

0 comments on commit a9f2a5a

Please sign in to comment.