b2b-platform-utils 1.1.83 → 1.1.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/optimizeMedia.js +11 -1
- package/package.json +1 -1
package/optimizeMedia.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Purpose: Image optimization helpers powered by Sharp.
|
|
4
4
|
|
|
5
5
|
const sharp = require('sharp');
|
|
6
|
+
const { getValue } = require('./localCache');
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Convert a buffer to resized WebP with adjustable quality and alpha quality.
|
|
@@ -233,9 +234,18 @@ async function optimizeImageBufferByFormat(fileDataBuffer, originalFileType, opt
|
|
|
233
234
|
...options
|
|
234
235
|
};
|
|
235
236
|
|
|
236
|
-
const passthroughFormats = buildPassthroughFormats(opts);
|
|
237
237
|
let normalizedType = normalizeImageFileType(originalFileType);
|
|
238
238
|
|
|
239
|
+
if (getValue('disableImageOptimization') === true) {
|
|
240
|
+
return {
|
|
241
|
+
buffer: fileDataBuffer,
|
|
242
|
+
fileType: normalizedType || 'bin',
|
|
243
|
+
optimized: false
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const passthroughFormats = buildPassthroughFormats(opts);
|
|
248
|
+
|
|
239
249
|
try {
|
|
240
250
|
if (normalizedType && passthroughFormats.has(normalizedType)) {
|
|
241
251
|
return { buffer: fileDataBuffer, fileType: normalizedType, optimized: false };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "b2b-platform-utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.84",
|
|
4
4
|
"description": "Shared utilities for Node.js microservices: errors map, local cache, logger, numbers, dates, filesystem, media optimization, paginator, slugger, crypto wrapper, sanitize HTML, sorting.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "KingSizer",
|