@wix/image-kit
Advanced tools
Comparing version 1.36.0 to 1.37.0
@@ -36,5 +36,6 @@ "use strict"; | ||
isSEOBot, | ||
shouldLoadHQImage | ||
shouldLoadHQImage, | ||
hasAnimation | ||
} = options; | ||
const canTransformImage = (0, _imageServiceUtils.isImageTransformApplicable)(src.id); | ||
const canTransformImage = (0, _imageServiceUtils.isImageTransformApplicable)(src.id, hasAnimation); | ||
if (!canTransformImage || shouldLoadHQImage) { | ||
@@ -76,3 +77,4 @@ /* Either: | ||
blur | ||
} : {} | ||
} : {}, | ||
hasAnimation | ||
}); | ||
@@ -79,0 +81,0 @@ const { |
@@ -28,3 +28,3 @@ "use strict"; | ||
const preferredExtension = fileExtension; | ||
const canTransformImage = (0, _imageServiceUtils.isImageTransformApplicable)(src.id); | ||
const canTransformImage = (0, _imageServiceUtils.isImageTransformApplicable)(src.id, options == null ? void 0 : options.hasAnimation); | ||
const transformsObj = { | ||
@@ -31,0 +31,0 @@ fileName, |
@@ -21,3 +21,3 @@ "use strict"; | ||
// check if image transformation is applicable (e.g. .gif, .wix_mp) | ||
if ((0, _imageServiceUtils.isImageTransformApplicable)(src.id)) { | ||
if ((0, _imageServiceUtils.isImageTransformApplicable)(src.id, options == null ? void 0 : options.hasAnimation)) { | ||
transformObj = transformObj || (0, _transform.getTransform)(fittingType, src, target, options); | ||
@@ -24,0 +24,0 @@ |
@@ -27,3 +27,3 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
const SUPPORTED_IMAGE_EXTENSIONS = [_imageServiceConstants.fileType.PNG, _imageServiceConstants.fileType.JPEG, _imageServiceConstants.fileType.JPG, _imageServiceConstants.fileType.JPE, _imageServiceConstants.fileType.WIX_ICO_MP, _imageServiceConstants.fileType.WIX_MP]; | ||
const SUPPORTED_IMAGE_EXTENSIONS = [_imageServiceConstants.fileType.PNG, _imageServiceConstants.fileType.JPEG, _imageServiceConstants.fileType.JPG, _imageServiceConstants.fileType.JPE, _imageServiceConstants.fileType.WIX_ICO_MP, _imageServiceConstants.fileType.WIX_MP, _imageServiceConstants.fileType.WEBP]; | ||
const JPG_EXTENSIONS = [_imageServiceConstants.fileType.JPEG, _imageServiceConstants.fileType.JPG, _imageServiceConstants.fileType.JPE]; | ||
@@ -59,7 +59,19 @@ | ||
*/ | ||
function isImageTransformApplicable(uri) { | ||
return isImageTypeSupported(uri) && !isExternalUrl(uri); | ||
function isImageTransformApplicable(uri, hasAnimation) { | ||
return !isNotTransformableWEBP(uri, hasAnimation) && isImageTypeSupported(uri) && !isExternalUrl(uri); | ||
} | ||
/** | ||
* returns true if image is of WEBP type and could be animated | ||
* (ie. image has hasAnimation true or was added before hasAnimation flag was created) | ||
* | ||
* @param {string} uri | ||
* @param {boolean} hasAnimation | ||
* @returns {boolean} | ||
*/ | ||
function isNotTransformableWEBP(uri, hasAnimation = true) { | ||
return isWEBP(uri) && hasAnimation; | ||
} | ||
/** | ||
* returns true if image is of JPG type | ||
@@ -66,0 +78,0 @@ * @param {string} uri |
@@ -54,3 +54,4 @@ "use strict"; | ||
const isJPG = transformsObj.fileType === _imageServiceConstants.fileType.JPG; | ||
const isQualitySupported = isJPG || isPNG; | ||
const isWEBP = transformsObj.fileType === _imageServiceConstants.fileType.WEBP; | ||
const isQualitySupported = isJPG || isPNG || isWEBP; | ||
if (isQualitySupported) { | ||
@@ -57,0 +58,0 @@ const transformData = (0, _utils.last)(transformsObj.parts); |
@@ -24,4 +24,4 @@ import { emptyData } from '../../helpers/imageServiceConstants'; | ||
} | ||
const { autoEncode = true, isSEOBot, shouldLoadHQImage } = options; | ||
const canTransformImage = isImageTransformApplicable(src.id); | ||
const { autoEncode = true, isSEOBot, shouldLoadHQImage, hasAnimation, } = options; | ||
const canTransformImage = isImageTransformApplicable(src.id, hasAnimation); | ||
if (!canTransformImage || shouldLoadHQImage) { | ||
@@ -46,2 +46,3 @@ /* Either: | ||
filters: blur ? { blur } : {}, | ||
hasAnimation, | ||
}); | ||
@@ -48,0 +49,0 @@ const { attr = {}, css } = getData(fittingType, src, Object.assign(Object.assign({}, newTarget), { alignment, |
@@ -23,3 +23,3 @@ import { isSEOBot, getFileType, getFileName, getFileExtension, getDevicePixelRatio, getUpscaleString, isImageTransformApplicable, } from '../helpers/imageServiceUtils'; | ||
const preferredExtension = fileExtension; | ||
const canTransformImage = isImageTransformApplicable(src.id); | ||
const canTransformImage = isImageTransformApplicable(src.id, options === null || options === void 0 ? void 0 : options.hasAnimation); | ||
const transformsObj = { | ||
@@ -26,0 +26,0 @@ fileName, |
@@ -17,3 +17,3 @@ import { isImageTransformApplicable } from '../helpers/imageServiceUtils'; | ||
// check if image transformation is applicable (e.g. .gif, .wix_mp) | ||
if (isImageTransformApplicable(src.id)) { | ||
if (isImageTransformApplicable(src.id, options === null || options === void 0 ? void 0 : options.hasAnimation)) { | ||
transformObj = | ||
@@ -20,0 +20,0 @@ transformObj || getTransform(fittingType, src, target, options); |
@@ -10,2 +10,3 @@ import { alignTypes, alignTypesMap, fileType, fittingTypes, imageQuality, imageScaleDefaults, transformTypes, upscaleMethods, upscaleMethodsValues, ALIGN_TYPE_TO_FOCAL_POINT, MAX_DEVICE_PIXEL_RATIO, SUPER_UPSCALE_MODELS, SAFE_TRANSFORMED_AREA, } from './imageServiceConstants'; | ||
fileType.WIX_MP, | ||
fileType.WEBP, | ||
]; | ||
@@ -46,6 +47,19 @@ const JPG_EXTENSIONS = [ | ||
*/ | ||
function isImageTransformApplicable(uri) { | ||
return isImageTypeSupported(uri) && !isExternalUrl(uri); | ||
function isImageTransformApplicable(uri, hasAnimation) { | ||
return (!isNotTransformableWEBP(uri, hasAnimation) && | ||
isImageTypeSupported(uri) && | ||
!isExternalUrl(uri)); | ||
} | ||
/** | ||
* returns true if image is of WEBP type and could be animated | ||
* (ie. image has hasAnimation true or was added before hasAnimation flag was created) | ||
* | ||
* @param {string} uri | ||
* @param {boolean} hasAnimation | ||
* @returns {boolean} | ||
*/ | ||
function isNotTransformableWEBP(uri, hasAnimation = true) { | ||
return isWEBP(uri) && hasAnimation; | ||
} | ||
/** | ||
* returns true if image is of JPG type | ||
@@ -52,0 +66,0 @@ * @param {string} uri |
@@ -48,3 +48,4 @@ import { last } from './utils'; | ||
const isJPG = transformsObj.fileType === fileType.JPG; | ||
const isQualitySupported = isJPG || isPNG; | ||
const isWEBP = transformsObj.fileType === fileType.WEBP; | ||
const isQualitySupported = isJPG || isPNG || isWEBP; | ||
if (isQualitySupported) { | ||
@@ -51,0 +52,0 @@ const transformData = last(transformsObj.parts); |
@@ -24,3 +24,3 @@ import type { FileType, FittingType, TransformType, UpscaleMethod, ImageTransformData, ImageTransformOptions, ImageTransformSource, ImageTransformTarget } from '../types'; | ||
*/ | ||
declare function isImageTransformApplicable(uri: string): boolean; | ||
declare function isImageTransformApplicable(uri: string, hasAnimation?: boolean): boolean; | ||
/** | ||
@@ -27,0 +27,0 @@ * returns true if image is of PNG type |
@@ -165,2 +165,3 @@ export type FittingType = 'fill' | 'fit' | 'stretch' | 'original_size' | 'tile' | 'legacy_fill' | 'tile_horizontal' | 'tile_vertical' | 'fit_and_tile' | 'legacy_strip_tile' | 'legacy_strip_tile_horizontal' | 'legacy_strip_tile_vertical' | 'legacy_strip_fill' | 'legacy_strip_fit' | 'legacy_strip_fit_and_tile' | 'legacy_strip_original_size' | 'actual_size' | 'fitWidth' | 'fitHeight' | 'full' | 'legacy_tile' | 'legacy_tile_horizontal' | 'legacy_tile_vertical' | 'legacy_normal'; | ||
useSrcset?: boolean; | ||
hasAnimation?: boolean; | ||
}; | ||
@@ -167,0 +168,0 @@ export type ImageTransformObjectPart = TransformCropPart | TransformFitPart | TransformFillPart | TransformLegacyFitPart | TransformLegacyFillPart | TransformLegacyCropPart; |
{ | ||
"name": "@wix/image-kit", | ||
"description": "Standard library for generating canonical URL's for optimally consuming images at Wix", | ||
"version": "1.36.0", | ||
"version": "1.37.0", | ||
"license": "MIT", | ||
@@ -44,4 +44,4 @@ "author": { | ||
"@types/node": "^16.0.0", | ||
"@wix/jest-yoshi-preset": "^6.68.0", | ||
"@wix/yoshi-flow-library": "^6.68.0", | ||
"@wix/jest-yoshi-preset": "^6.72.1", | ||
"@wix/yoshi-flow-library": "^6.72.1", | ||
"husky": "~4.2.1", | ||
@@ -68,3 +68,3 @@ "jsdom": "^19.0.0", | ||
}, | ||
"falconPackageHash": "66d8b580aab8fe1d7812760578574cd7548f07dc53c28ac875954998" | ||
"falconPackageHash": "d17a47c63a2c4b8e9ba24182fa4890f317e94b32acd6f721259f9ef0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
546612
5621