Skip to content

Commit

Permalink
feat: support data-fullsize attribute
Browse files Browse the repository at this point in the history
Instructs jampack not to do srcset manipulations on the given
image element
  • Loading branch information
muryoh committed Aug 26, 2024
1 parent 498fa10 commit bbb3002
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@divriots/jampack",
"version": "0.25.0",
"version": "0.26.0",
"cache-version": {
"img": "v1",
"img-ext": "v1"
Expand Down
7 changes: 6 additions & 1 deletion src/optimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -365,6 +369,7 @@ async function processImage(
)
)
break;
if (fullSize) return;
let attrib_width = getIntAttr(img, 'width');
if (!attrib_width) {
state.reportIssue(htmlfile, {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bbb3002

Please sign in to comment.