shopify-images

A generic Javascript utility for Shopify's img_url filter

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
shopify-images
1.0.05 years ago5 years agoMinified + gzip package size for shopify-images in KB

Readme

Shopify Images #
A generic Javascript utility for Shopify imgurl size parameters.

Installation ##

# with NPM
npm install --save shopify-images

# or with Yarn
yarn add shopify-images

Usage ##

const ShopifyImage = require('shopify-images');

const imageSrc = '//cdn.shopify.com/s/files/1/1405/0664/products/4791207-9790062099-Pizza1.jpg';
const options = {
  size: 'x320'
};

ShopifyImage(imageSrc, options);
// => '//cdn.shopify.com/s/files/1/1405/0664/products/4791207-9790062099-Pizza1_x320.jpg'

Options ##

Options should be passed as an object. Please see Shopify's size parameters for documentation.
All Options
{
  size: '320x320',
  crop: 'center',
  scale: '2',
  format: 'pjg'
}

This will translate to...
//cdn.shopify.com/s/files/1/1405/0664/products/4791207-9790062099-Pizza1_320x320_center@2x.progressive.jpg