Skip to content

Commit

Permalink
Merge pull request TeamNewPipe#10377 from TeamNewPipe/image-minimizer
Browse files Browse the repository at this point in the history
Image minizier: replace Number.toFixed(0) with Math.floor()
  • Loading branch information
TobiGr authored Aug 24, 2023
2 parents d09c650 + 510db56 commit 25cf917
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/image-minimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = async ({github, context}) => {
});
}

// Asnyc replace function from https://stackoverflow.com/a/48032528
// Async replace function from https://stackoverflow.com/a/48032528
async function replaceAsync(str, regex, asyncFn) {
const promises = [];
str.replace(regex, (match, ...args) => {
Expand Down Expand Up @@ -138,7 +138,7 @@ module.exports = async ({github, context}) => {
if (shouldModify) {
wasMatchModified = true;
console.log(`Modifying match '${match}'`);
return `<img alt="${g1}" src="${g2}" width=${Math.min(600, (IMG_MAX_HEIGHT_PX * probeAspectRatio).toFixed(0))} />`;
return `<img alt="${g1}" src="${g2}" width=${Math.min(600, Math.floor(IMG_MAX_HEIGHT_PX * probeAspectRatio))} />`;
}

console.log(`Match '${match}' is ok/will not be modified`);
Expand Down

0 comments on commit 25cf917

Please sign in to comment.