responsive-loader
Advanced tools
Comparing version 1.0.0 to 1.1.0
# Change Log | ||
## v1.0.0 [Unreleased] | ||
## v1.1.0 | ||
- Added `min` and `max` options to automatically generate a number of images, and `steps` option to say how many images ([#31](https://github.com/herrstucki/responsive-loader/pull/31)). | ||
## v1.0.0 | ||
### New | ||
@@ -6,0 +10,0 @@ |
@@ -21,3 +21,2 @@ 'use strict'; | ||
var config = Object.assign({}, loaderUtils.getOptions(this), parsedResourceQuery); | ||
var sizes = config.size || config.sizes || [Number.MAX_SAFE_INTEGER]; | ||
var outputContext = config.context || ''; | ||
@@ -58,2 +57,18 @@ var outputPlaceholder = Boolean(config.placeholder) || false; | ||
var min = config.min !== undefined ? parseInt(config.min, 10) : undefined; | ||
var max = config.max !== undefined ? parseInt(config.max, 10) : undefined; | ||
var steps = config.steps === undefined ? 4 : parseInt(config.steps, 10); | ||
var generatedSizes = void 0; | ||
if (typeof min === 'number' && max) { | ||
generatedSizes = []; | ||
for (var step = 0; step < steps; step++) { | ||
var _size = min + (max - min) / (steps - 1) * step; | ||
generatedSizes.push(Math.ceil(_size)); | ||
} | ||
} | ||
var sizes = parsedResourceQuery.size || parsedResourceQuery.sizes || generatedSizes || config.size || config.sizes || [Number.MAX_SAFE_INTEGER]; | ||
if (!sizes) { | ||
@@ -60,0 +75,0 @@ return loaderCallback(null, content); |
{ | ||
"name": "responsive-loader", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A webpack loader for responsive images", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -116,2 +116,5 @@ # responsive-loader | ||
- `size: integer` — specify one width you want to use; if the specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up) | ||
- `min: integer` - as an alternative to manually specifying `sizes`, you can specify `min`, `max` and `steps`, and the sizes will be generated for you. | ||
- `max: integer` - see `min` above | ||
- `steps: integer` - configure the number of images generated between `min` and `max` (inclusive). Defaults to 4. | ||
- `quality: integer` — JPEG compression quality; defaults to `85` | ||
@@ -118,0 +121,0 @@ - `format: string` — either `png` or `jpg`; use to convert to another format; default format is inferred from the source file's extension |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22012
210
194