nxify
Nxify allows you to modify your image urls based on the pixel ratio of the user's device.
Installation
$ npm install nxify
Usage
var nxify = ; var url = '/path/to/your/image.jpg'; if windowdevicePixelRatio > 1 url = ; console; // output: 'path/to/your/image@2x.jpg'
You can set your custom pixel ratio multiplier as the second parameter:
var nxify = ; var url = ; console; // output: 'path/to/your/image@3x.png'
Arguments
It waits for two parameters
- path (String) path to the image you'd like to modify
- [pixelRatio=2] the pixel ratio multiplier (default: 2)
Tests
$ npm test