Skip to content

Commit

Permalink
Merge pull request #189 from divriots/feat/data-fullsize
Browse files Browse the repository at this point in the history
feat: support data-fullsize attribute
  • Loading branch information
muryoh authored Aug 27, 2024
2 parents 498fa10 + bbb3002 commit 63c10d7
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 63c10d7

Please sign in to comment.