bbc / Imager.js

Responsive images while we wait for srcset to finish cooking
Apache License 2.0
3.84k stars 224 forks source link

widthInterpolator to accept a pixelRatio parameter #109

Closed thom4parisot closed 9 years ago

thom4parisot commented 9 years ago

The widthInterpolator now accepts a second parameter pixelRatio in addition to the existing width one. It is handy if you do not build image@2x.jpg but rather use browser image scaling.

The following example will multiply the availableWidth by the device pixel ratio:

new Imager({
  availableWidths: [200, 260, 320, 600],
  widthInterpolator: function(width, ratio) {
    return width * ratio;
  }
});

// if pixelRatio is 2, availableWidths === [400, 520, 640, 1200]
// if pixelRatio is 3, availableWidths === [600, 780, 960, 1800]

closes #84