From bbb300259d02c24ecbff21ef81dd9c7b4a5a3f6b Mon Sep 17 00:00:00 2001 From: Remy Date: Mon, 26 Aug 2024 11:44:00 +0200 Subject: [PATCH] feat: support data-fullsize attribute Instructs jampack not to do srcset manipulations on the given image element --- package.json | 2 +- src/optimize.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a84a2d1..532df2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@divriots/jampack", - "version": "0.25.0", + "version": "0.26.0", "cache-version": { "img": "v1", "img-ext": "v1" diff --git a/src/optimize.ts b/src/optimize.ts index 0ea6b24..e72d641 100755 --- a/src/optimize.ts +++ b/src/optimize.ts @@ -278,6 +278,10 @@ async function processImage( return; } + const fullSizeRaw = img.attr('data-fullsize'); + if (typeof fullSizeRaw !== undefined) img.removeAttr('data-fullsize'); + const fullSize = !!fullSizeRaw && parseInt(fullSizeRaw) > 0; + const config = state.options; if ( @@ -365,6 +369,7 @@ async function processImage( ) ) break; + if (fullSize) return; let attrib_width = getIntAttr(img, 'width'); if (!attrib_width) { state.reportIssue(htmlfile, { @@ -604,7 +609,7 @@ async function processImage( // If srcset are set, don't touch it. // The compress pass will compress the images // of the srcset - } else { + } else if (!fullSize) { const new_srcset = await generateSrcSet( state, htmlfile,