Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudimage-responsive-utils

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudimage-responsive-utils - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1-beta.0

318

dist/index.js

@@ -8,110 +8,6 @@ "use strict";

});
Object.defineProperty(exports, "isServer", {
enumerable: true,
get: function get() {
return _isServer.isServer;
}
});
Object.defineProperty(exports, "getImgSRC", {
enumerable: true,
get: function get() {
return _getImgSrc.getImgSRC;
}
});
Object.defineProperty(exports, "getBreakpoint", {
enumerable: true,
get: function get() {
return _getBreakpoint.getBreakpoint;
}
});
Object.defineProperty(exports, "getPreviewSRC", {
enumerable: true,
get: function get() {
return _getPreviewSrc.getPreviewSRC;
}
});
Object.defineProperty(exports, "getSizeLimit", {
enumerable: true,
get: function get() {
return _getSizeLimit.getSizeLimit;
}
});
Object.defineProperty(exports, "getParentContainerSize", {
enumerable: true,
get: function get() {
return _getParentContainerSize.getParentContainerSize;
}
});
Object.defineProperty(exports, "getWidth", {
enumerable: true,
get: function get() {
return _getWidth.getWidth;
}
});
Object.defineProperty(exports, "getHeight", {
enumerable: true,
get: function get() {
return _getHeight.getHeight;
}
});
Object.defineProperty(exports, "getRatio", {
enumerable: true,
get: function get() {
return _getRatio.getRatio;
}
});
Object.defineProperty(exports, "getParamsFromURL", {
enumerable: true,
get: function get() {
return _getParamsFromUrl.getParamsFromURL;
}
});
Object.defineProperty(exports, "isSVG", {
enumerable: true,
get: function get() {
return _isSvg.isSVG;
}
});
Object.defineProperty(exports, "isCrop", {
enumerable: true,
get: function get() {
return _isCrop.isCrop;
}
});
Object.defineProperty(exports, "isLowQualityPreview", {
enumerable: true,
get: function get() {
return _isLowQualityPreview.isLowQualityPreview;
}
});
Object.defineProperty(exports, "isSupportedInBrowser", {
enumerable: true,
get: function get() {
return _isSupportedInBrowser.isSupportedInBrowser;
}
});
Object.defineProperty(exports, "generateURL", {
enumerable: true,
get: function get() {
return _generateUrl.generateURL;
}
});
Object.defineProperty(exports, "processReactNode", {
enumerable: true,
get: function get() {
return _processReactNode.processReactNode;
}
});
Object.defineProperty(exports, "processParams", {
enumerable: true,
get: function get() {
return _processParams.processParams;
}
});
Object.defineProperty(exports, "convertToPX", {
enumerable: true,
get: function get() {
return _convertToPx.convertToPX;
}
});
var _exportNames = {
blurhash: true,
CONSTANTS: true
};
exports.CONSTANTS = exports.blurhash = void 0;

@@ -121,46 +17,244 @@

Object.keys(_isServer).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _isServer[key];
}
});
});
var _getImgSrc = require("./utils/get-img-src");
Object.keys(_getImgSrc).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getImgSrc[key];
}
});
});
var _getBreakpoint = require("./utils/get-breakpoint");
Object.keys(_getBreakpoint).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getBreakpoint[key];
}
});
});
var _getPreviewSrc = require("./utils/get-preview-src");
Object.keys(_getPreviewSrc).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getPreviewSrc[key];
}
});
});
var _getSizeLimit = require("./utils/get-size-limit");
Object.keys(_getSizeLimit).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getSizeLimit[key];
}
});
});
var _getParentContainerSize = require("./utils/get-parent-container-size");
Object.keys(_getParentContainerSize).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getParentContainerSize[key];
}
});
});
var _getWidth = require("./utils/get-width");
Object.keys(_getWidth).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getWidth[key];
}
});
});
var _getHeight = require("./utils/get-height");
Object.keys(_getHeight).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getHeight[key];
}
});
});
var _getRatio = require("./utils/get-ratio");
Object.keys(_getRatio).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getRatio[key];
}
});
});
var _getParamsFromUrl = require("./utils/get-params-from-url");
Object.keys(_getParamsFromUrl).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _getParamsFromUrl[key];
}
});
});
var _isSvg = require("./utils/is-svg");
Object.keys(_isSvg).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _isSvg[key];
}
});
});
var _isCrop = require("./utils/is-crop");
Object.keys(_isCrop).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _isCrop[key];
}
});
});
var _isLowQualityPreview = require("./utils/is-low-quality-preview");
Object.keys(_isLowQualityPreview).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _isLowQualityPreview[key];
}
});
});
var _isSupportedInBrowser = require("./utils/is-supported-in-browser");
Object.keys(_isSupportedInBrowser).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _isSupportedInBrowser[key];
}
});
});
var _generateUrl = require("./utils/generate-url");
Object.keys(_generateUrl).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _generateUrl[key];
}
});
});
var _processReactNode = require("./utils/process-react-node");
Object.keys(_processReactNode).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _processReactNode[key];
}
});
});
var _processParams = require("./utils/process-params");
Object.keys(_processParams).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _processParams[key];
}
});
});
var _convertToPx = require("./utils/convert-to-px");
var blurhash = _interopRequireWildcard(require("./libs/blur-hash"));
Object.keys(_convertToPx).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _convertToPx[key];
}
});
});
exports.blurhash = blurhash;
var _blurhash = _interopRequireWildcard(require("./libs/blur-hash"));
var CONSTANTS = _interopRequireWildcard(require("./constants"));
exports.blurhash = _blurhash;
exports.CONSTANTS = CONSTANTS;
var _CONSTANTS = _interopRequireWildcard(require("./constants"));
exports.CONSTANTS = _CONSTANTS;
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -22,3 +22,3 @@ "use strict";

* @param {Boolean} props.exactSize - a flag to use exact width/height params
* @param {Number} props.imageNodeHeight - height of image node
* @param {Number} props.imgNodeHeight - height of image node
* @param {String} props.params - params of image node

@@ -32,4 +32,4 @@ * @return {Number} height limit

config = _props$config === void 0 ? {} : _props$config,
_props$imageNodeHeigh = props.imageNodeHeight,
imageNodeHeight = _props$imageNodeHeigh === void 0 ? null : _props$imageNodeHeigh,
_props$imgNodeHeight = props.imgNodeHeight,
imgNodeHeight = _props$imgNodeHeight === void 0 ? null : _props$imgNodeHeight,
_props$params = props.params,

@@ -45,3 +45,3 @@ params = _props$params === void 0 ? {} : _props$params,

var paramsHeight = params.height || params.h;
var imageNodeHeightPX = !ignoreNodeImgSize && imageNodeHeight && (0, _index.convertToPX)(imageNodeHeight);
var imgNodeHeightPX = !ignoreNodeImgSize && imgNodeHeight && (0, _index.convertToPX)(imgNodeHeight);
var imageHeight = !ignoreStyleImgSize && getImageHeight(imgNode);

@@ -62,4 +62,4 @@ var imageContainerHeight = !imageHeight && parseInt((0, _index.getParentContainerSize)(imgNode, 'height'), 10);

if (!ignoreNodeImgSize && imageNodeHeight) {
return imageNodeHeightPX;
if (!ignoreNodeImgSize && imgNodeHeight) {
return imgNodeHeightPX;
}

@@ -66,0 +66,0 @@

@@ -9,3 +9,3 @@ "use strict";

var getRatio = function getRatio(_ref) {
var imageNodeRatio = _ref.imageNodeRatio,
var imgNodeRatio = _ref.imgNodeRatio,
width = _ref.width,

@@ -15,4 +15,4 @@ height = _ref.height,

config = _ref.config,
imageNodeWidth = _ref.imageNodeWidth,
imageNodeHeight = _ref.imageNodeHeight;
imgNodeWidth = _ref.imgNodeWidth,
imgNodeHeight = _ref.imgNodeHeight;
var saveNodeImgRatio = config.saveNodeImgRatio,

@@ -31,6 +31,6 @@ ignoreNodeImgSize = config.ignoreNodeImgSize;

if (!ignoreNodeImgSize && imageNodeRatio) {
return imageNodeRatio;
} else if (saveNodeImgRatio && imageNodeWidth && imageNodeHeight) {
return imageNodeWidth / imageNodeHeight;
if (!ignoreNodeImgSize && imgNodeRatio) {
return imgNodeRatio;
} else if (saveNodeImgRatio && imgNodeWidth && imgNodeHeight) {
return imgNodeWidth / imgNodeHeight;
} else if (width && height) {

@@ -37,0 +37,0 @@ return width / height;

@@ -20,3 +20,3 @@ "use strict";

* @param {HTMLImageElement} props.imgNode - image node
* @param {Number} props.imageNodeWidth - width of image node
* @param {Number} props.imgNodeWidth - width of image node
* @param {String} props.params - params of image node

@@ -27,4 +27,4 @@ * @return {Array} [with, isLimit]

var imgNode = props.imgNode,
_props$imageNodeWidth = props.imageNodeWidth,
imageNodeWidth = _props$imageNodeWidth === void 0 ? null : _props$imageNodeWidth,
_props$imgNodeWidth = props.imgNodeWidth,
imgNodeWidth = _props$imgNodeWidth === void 0 ? null : _props$imgNodeWidth,
_props$params = props.params,

@@ -39,3 +39,3 @@ params = _props$params === void 0 ? {} : _props$params,

var paramsWidth = params.width || params.w;
var imageNodeWidthPX = !ignoreNodeImgSize && imageNodeWidth && (0, _.convertToPX)(imageNodeWidth);
var imgNodeWidthPX = !ignoreNodeImgSize && imgNodeWidth && (0, _.convertToPX)(imgNodeWidth);
var imageWidth = !ignoreStyleImgSize && getImageWidth(imgNode, detectImageNodeCSS);

@@ -51,4 +51,4 @@ var imageContainerWidth = !imageWidth && parseInt((0, _.getParentContainerSize)(imgNode), 10);

if (!ignoreNodeImgSize && imageNodeWidth) {
return [imageNodeWidthPX];
if (!ignoreNodeImgSize && imgNodeWidth) {
return [imgNodeWidthPX];
}

@@ -66,4 +66,4 @@

if (!ignoreNodeImgSize && imageNodeWidth) {
return [imageNodeWidthPX];
if (!ignoreNodeImgSize && imgNodeWidth) {
return [imgNodeWidthPX];
}

@@ -70,0 +70,0 @@

@@ -9,3 +9,3 @@ "use strict";

var processParams = function processParams(params) {
var resultParams = undefined;
var resultParams = {};

@@ -12,0 +12,0 @@ try {

@@ -10,2 +10,4 @@ "use strict";

var _constants = require("../constants");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -39,3 +41,4 @@

presets = config.presets,
minLowQualityWidth = config.minLowQualityWidth;
minLowQualityWidth = config.minLowQualityWidth,
devicePixelRatioList = config.devicePixelRatioList;
if (!imgNodeSRC) return;

@@ -63,7 +66,19 @@

var preview = lowQualityPreview && (0, _.isLowQualityPreview)(adaptive, width, svg, minLowQualityWidth);
var cloudimgURL = !adaptive && svg ? src : (0, _.generateURL)({
src: src,
params: params,
config: config,
containerProps: containerProps
var generateURLbyDPR = function generateURLbyDPR(devicePixelRatio) {
return !adaptive && svg ? src : (0, _.generateURL)({
src: src,
params: params,
config: config,
containerProps: containerProps,
devicePixelRatio: devicePixelRatio
});
};
var cloudimgURL = generateURLbyDPR();
var cloudimgSRCSET = devicePixelRatioList.map(function (dpr) {
return {
dpr: dpr.toString(),
url: generateURLbyDPR(dpr)
};
});

@@ -83,2 +98,3 @@

previewCloudimgURL: previewCloudimgURL,
cloudimgSRCSET: cloudimgSRCSET,
processed: true,

@@ -113,5 +129,5 @@ preview: preview

config = _props$config === void 0 ? {} : _props$config,
imageNodeWidth = props.imageNodeWidth,
imageNodeHeight = props.imageNodeHeight,
imageNodeRatio = props.imageNodeRatio,
imgNodeWidth = props.imgNodeWidth,
imgNodeHeight = props.imgNodeHeight,
imgNodeRatio = props.imgNodeRatio,
params = props.params,

@@ -129,3 +145,3 @@ size = props.size;

exactSize: exactSize,
imageNodeWidth: imageNodeWidth,
imgNodeWidth: imgNodeWidth,
params: _objectSpread({}, config.params, {}, params),

@@ -142,5 +158,5 @@ size: size

exactSize: exactSize,
imageNodeHeight: imageNodeHeight,
imageNodeWidth: imageNodeWidth,
imageNodeRatio: imageNodeRatio,
imgNodeHeight: imgNodeHeight,
imgNodeWidth: imgNodeWidth,
imgNodeRatio: imgNodeRatio,
params: _objectSpread({}, config.params, {}, params),

@@ -151,3 +167,3 @@ size: size,

ratio = (0, _.getRatio)({
imageNodeRatio: imageNodeRatio,
imgNodeRatio: imgNodeRatio,
width: width,

@@ -157,6 +173,7 @@ height: height,

config: config,
imageNodeWidth: imageNodeWidth,
imageNodeHeight: imageNodeHeight
imgNodeWidth: imgNodeWidth,
imgNodeHeight: imgNodeHeight
});
var sizes = DEVICE_PIXEL_RATIO_LIST.map(function (dpr) {
var sizes = _constants.DEVICE_PIXEL_RATIO_LIST.map(function (dpr) {
var widthWithDPR, heightWithDRP;

@@ -181,2 +198,3 @@ widthWithDPR = width && width * dpr;

});
return {

@@ -183,0 +201,0 @@ sizes: sizes,

{
"name": "cloudimage-responsive-utils",
"version": "2.0.0",
"version": "2.0.1-beta.0",
"description": "cloudimage responsive utils",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -1,53 +0,83 @@

/*
* utils
* */
import { isServer } from './utils/is-server';
import { getImgSRC } from './utils/get-img-src';
import { getBreakpoint } from './utils/get-breakpoint';
import { getPreviewSRC } from './utils/get-preview-src';
import { getSizeLimit } from './utils/get-size-limit';
import { getParentContainerSize } from './utils/get-parent-container-size';
import { getWidth } from './utils/get-width';
import { getHeight } from './utils/get-height';
import { getRatio } from './utils/get-ratio';
import { getParamsFromURL } from './utils/get-params-from-url';
import { isSVG } from './utils/is-svg';
import { isCrop } from './utils/is-crop';
import { isLowQualityPreview } from './utils/is-low-quality-preview';
import { isSupportedInBrowser } from './utils/is-supported-in-browser';
import { generateURL } from './utils/generate-url';
import { processReactNode } from './utils/process-react-node';
import { processParams } from './utils/process-params';
import { convertToPX } from './utils/convert-to-px';
/*
* libs
* */
import * as blurhash from './libs/blur-hash';
/*
* Constants
* */
import * as CONSTANTS from './constants';
///*
//* utils
//* */
export * from './utils/is-server';
export * from './utils/get-img-src';
export * from './utils/get-breakpoint';
export * from './utils/get-preview-src';
export * from './utils/get-size-limit';
export * from './utils/get-parent-container-size';
export * from './utils/get-width';
export * from './utils/get-height';
export * from './utils/get-ratio';
export * from './utils/get-params-from-url';
export * from './utils/is-svg';
export * from './utils/is-crop';
export * from './utils/is-low-quality-preview';
export * from './utils/is-supported-in-browser';
export * from './utils/generate-url';
export * from './utils/process-react-node';
export * from './utils/process-params';
export * from './utils/convert-to-px';
//* libs
//* */
export * as blurhash from './libs/blur-hash';
///*
//* Constants
//* */
export * as CONSTANTS from './constants';
export {
isServer,
getImgSRC,
getBreakpoint,
getPreviewSRC,
getSizeLimit,
getParentContainerSize,
getWidth,
getHeight,
getRatio,
getParamsFromURL,
isSVG,
isLowQualityPreview,
isSupportedInBrowser,
generateURL,
processParams,
processReactNode,
convertToPX,
blurhash,
isCrop,
CONSTANTS
};
///*
//* utils
//* */
//import { isServer } from './utils/is-server';
//import { getImgSRC } from './utils/get-img-src';
//import { getBreakpoint } from './utils/get-breakpoint';
//import { getPreviewSRC } from './utils/get-preview-src';
//import { getSizeLimit } from './utils/get-size-limit';
//import { getParentContainerSize } from './utils/get-parent-container-size';
//import { getWidth } from './utils/get-width';
//import { getHeight } from './utils/get-height';
//import { getRatio } from './utils/get-ratio';
//import { getParamsFromURL } from './utils/get-params-from-url';
//import { isSVG } from './utils/is-svg';
//import { isCrop } from './utils/is-crop';
//import { isLowQualityPreview } from './utils/is-low-quality-preview';
//import { isSupportedInBrowser } from './utils/is-supported-in-browser';
//import { generateURL } from './utils/generate-url';
//import { processReactNode } from './utils/process-react-node';
//import { processParams } from './utils/process-params';
//import { convertToPX } from './utils/convert-to-px';
///*
//* libs
//* */
//import * as blurhash from './libs/blur-hash';
///*
//* Constants
//* */
//import * as CONSTANTS from './constants';
//
//
//export {
// isServer,
// getImgSRC,
// getBreakpoint,
// getPreviewSRC,
// getSizeLimit,
// getParentContainerSize,
// getWidth,
// getHeight,
// getRatio,
// getParamsFromURL,
// isSVG,
// isLowQualityPreview,
// isSupportedInBrowser,
// generateURL,
// processParams,
// processReactNode,
// convertToPX,
// blurhash,
// isCrop,
// CONSTANTS
//};

@@ -16,3 +16,3 @@ import { convertToPX, getParentContainerSize, isCrop } from '../index';

* @param {Boolean} props.exactSize - a flag to use exact width/height params
* @param {Number} props.imageNodeHeight - height of image node
* @param {Number} props.imgNodeHeight - height of image node
* @param {String} props.params - params of image node

@@ -22,3 +22,3 @@ * @return {Number} height limit

export const getHeight = props => {
const { imgNode = null, config = {}, imageNodeHeight = null, params = {}, size, width } = props;
const { imgNode = null, config = {}, imgNodeHeight = null, params = {}, size, width } = props;
const { ignoreNodeImgSize, ignoreStyleImgSize } = config;

@@ -29,3 +29,3 @@ const crop = isCrop(params.func || config.params.func);

const paramsHeight = params.height || params.h;
const imageNodeHeightPX = !ignoreNodeImgSize && imageNodeHeight && convertToPX(imageNodeHeight);
const imgNodeHeightPX = !ignoreNodeImgSize && imgNodeHeight && convertToPX(imgNodeHeight);
const imageHeight = !ignoreStyleImgSize && getImageHeight(imgNode);

@@ -46,4 +46,4 @@ const imageContainerHeight = !imageHeight && parseInt(getParentContainerSize(imgNode, 'height'), 10);

if (!ignoreNodeImgSize && imageNodeHeight) {
return imageNodeHeightPX;
if (!ignoreNodeImgSize && imgNodeHeight) {
return imgNodeHeightPX;
}

@@ -50,0 +50,0 @@

@@ -1,2 +0,2 @@

export const getRatio = ({ imageNodeRatio, width, height, size, config, imageNodeWidth, imageNodeHeight }) => {
export const getRatio = ({ imgNodeRatio, width, height, size, config, imgNodeWidth, imgNodeHeight }) => {
const { saveNodeImgRatio, ignoreNodeImgSize } = config;

@@ -14,6 +14,6 @@

if (!ignoreNodeImgSize && imageNodeRatio) {
return imageNodeRatio;
} else if (saveNodeImgRatio && imageNodeWidth && imageNodeHeight) {
return imageNodeWidth / imageNodeHeight;
if (!ignoreNodeImgSize && imgNodeRatio) {
return imgNodeRatio;
} else if (saveNodeImgRatio && imgNodeWidth && imgNodeHeight) {
return imgNodeWidth / imgNodeHeight;
} else if (width && height) {

@@ -20,0 +20,0 @@ return width / height;

@@ -14,3 +14,3 @@ import { convertToPX, getParentContainerSize } from '../';

* @param {HTMLImageElement} props.imgNode - image node
* @param {Number} props.imageNodeWidth - width of image node
* @param {Number} props.imgNodeWidth - width of image node
* @param {String} props.params - params of image node

@@ -20,7 +20,7 @@ * @return {Array} [with, isLimit]

export const getWidth = props => {
const { imgNode, imageNodeWidth = null, params = {}, size, config } = props;
const { imgNode, imgNodeWidth = null, params = {}, size, config } = props;
const { ignoreNodeImgSize, ignoreStyleImgSize, detectImageNodeCSS } = config;
const sizeParamsWidth = size && size.params && (size.params.w || size.params.width);
const paramsWidth = params.width || params.w;
const imageNodeWidthPX = !ignoreNodeImgSize && imageNodeWidth && convertToPX(imageNodeWidth);
const imgNodeWidthPX = !ignoreNodeImgSize && imgNodeWidth && convertToPX(imgNodeWidth);
const imageWidth = !ignoreStyleImgSize && getImageWidth(imgNode, detectImageNodeCSS);

@@ -36,4 +36,4 @@ const imageContainerWidth = !imageWidth && parseInt(getParentContainerSize(imgNode), 10);

if (!ignoreNodeImgSize && imageNodeWidth) {
return [imageNodeWidthPX];
if (!ignoreNodeImgSize && imgNodeWidth) {
return [imgNodeWidthPX];
}

@@ -51,4 +51,4 @@

if (!ignoreNodeImgSize && imageNodeWidth) {
return [imageNodeWidthPX];
if (!ignoreNodeImgSize && imgNodeWidth) {
return [imgNodeWidthPX];
}

@@ -55,0 +55,0 @@

export const processParams = (params) => {
let resultParams = undefined;
let resultParams = {};

@@ -4,0 +4,0 @@ try {

@@ -14,2 +14,3 @@ import {

} from '../';
import { DEVICE_PIXEL_RATIO_LIST } from '../constants';

@@ -21,3 +22,3 @@

const { config } = props;
const { baseURL, presets, minLowQualityWidth } = config;
const { baseURL, presets, minLowQualityWidth, devicePixelRatioList } = config;

@@ -38,3 +39,8 @@ if (!imgNodeSRC) return;

const preview = lowQualityPreview && isLowQualityPreview(adaptive, width, svg, minLowQualityWidth);
const cloudimgURL = !adaptive && svg ? src : generateURL({ src, params, config, containerProps });
const generateURLbyDPR = devicePixelRatio =>
!adaptive && svg ?
src :
generateURL({ src, params, config, containerProps, devicePixelRatio });
const cloudimgURL = generateURLbyDPR();
const cloudimgSRCSET = devicePixelRatioList.map(dpr => ({ dpr: dpr.toString(), url: generateURLbyDPR(dpr) }));

@@ -48,2 +54,3 @@ if (preview) {

previewCloudimgURL,
cloudimgSRCSET,
processed: true,

@@ -66,3 +73,3 @@ preview,

const determineContainerProps = props => {
const { imgNode, config = {}, imageNodeWidth, imageNodeHeight, imageNodeRatio, params, size } = props;
const { imgNode, config = {}, imgNodeWidth, imgNodeHeight, imgNodeRatio, params, size } = props;
const { ignoreNodeImgSize } = config;

@@ -73,3 +80,3 @@ let ratio = null;

let [width, isLimit] = getWidth({
imgNode, config, exactSize, imageNodeWidth, params: { ...config.params, ...params }, size
imgNode, config, exactSize, imgNodeWidth, params: { ...config.params, ...params }, size
});

@@ -80,5 +87,5 @@ let height = getHeight({

exactSize,
imageNodeHeight,
imageNodeWidth,
imageNodeRatio,
imgNodeHeight,
imgNodeWidth,
imgNodeRatio,
params: { ...config.params, ...params },

@@ -88,3 +95,3 @@ size,

});
ratio = getRatio({ imageNodeRatio, width, height, size, config, imageNodeWidth, imageNodeHeight });
ratio = getRatio({ imgNodeRatio, width, height, size, config, imgNodeWidth, imgNodeHeight });

@@ -91,0 +98,0 @@ const sizes = DEVICE_PIXEL_RATIO_LIST.map(dpr => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc