@ribajs/shopify
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "@ribajs/shopify", | ||
"description": "Shopify extension for Riba.js", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": "Pascal Garber <pascal@jumplink.eu>", | ||
@@ -44,5 +44,5 @@ "contributors": [], | ||
"dependencies": { | ||
"@ribajs/core": "^1.2.0", | ||
"@ribajs/i18n": "^1.2.0" | ||
"@ribajs/core": "^1.2.1", | ||
"@ribajs/i18n": "^1.2.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { IFormatter } from '@ribajs/core'; | ||
import { IFormatter, Utils } from '@ribajs/core'; | ||
@@ -15,7 +15,20 @@ /** | ||
name: 'img_url', | ||
read(url: string, size: string, scale: number, crop: string, extension: string) { | ||
read(url: string, size: string, scale?: number, crop?: string, extension?: string, element?: HTMLImageElement) { | ||
try { | ||
if ('original' === size || 'master' === size) { | ||
if (size === 'original' || size === 'master') { | ||
return url; | ||
} | ||
if (size === 'auto') { | ||
scale = window.devicePixelRatio; | ||
let width: number = 0; | ||
if (element) { | ||
width = element.offsetWidth; | ||
} else { | ||
width = Utils.getViewportDimensions().w; | ||
} | ||
size = width + 'x'; | ||
} | ||
if (scale && scale !== 1) { | ||
size += '@' + scale + 'x'; | ||
} | ||
const result = url.match(/(.*\/[\w\-\_\.]+)\.(\w{2,4})/); | ||
@@ -22,0 +35,0 @@ |
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
47535
29
1321
Updated@ribajs/core@^1.2.1
Updated@ribajs/i18n@^1.2.1