Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sizeInBytes on resized and optimized images #19707

Merged
merged 3 commits into from Mar 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/core/upload/server/services/image-manipulation.js
Expand Up @@ -59,7 +59,7 @@ const resizeFileTo = async (file, options, { name, hash }) => {

const { width, height, size } = await getMetadata(newFile);

Object.assign(newFile, { width, height, size: bytesToKbytes(size) });
Object.assign(newFile, { width, height, size: bytesToKbytes(size), sizeInBytes: size });
return newFile;
};

Expand Down Expand Up @@ -112,13 +112,14 @@ const optimize = async (file) => {

if (newSize > size) {
// Ignore optimization if output is bigger than original
return { ...file, width, height, size: bytesToKbytes(size) };
return { ...file, width, height, size: bytesToKbytes(size), sizeInBytes: size };
}

return Object.assign(newFile, {
width: newWidth,
height: newHeight,
size: bytesToKbytes(newSize),
sizeInBytes: newSize,
});
};

Expand Down