Socket
Book a DemoInstallSign in
Socket

nxify

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nxify

Nxify allows you to modify your image urls based on the pixel ratio of the user's device.

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

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 = require('nxify');

var url = '/path/to/your/image.jpg';

if (window.devicePixelRatio > 1) {
  url = nxify(url);
}

console.log(url); // output: 'path/to/your/image@2x.jpg'

You can set your custom pixel ratio multiplier as the second parameter:


var nxify = require('nxify');

var url = nxify('/path/to/your/image.png', 3);

console.log(url); // 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

License

MIT

FAQs

Package last updated on 08 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts