mirror of
https://github.com/vercel/commerce.git
synced 2025-07-05 12:41:21 +00:00
Use original product image by default instead of resized
This commit is contained in:
parent
92bb7bcf51
commit
e9397bcb72
@ -26,10 +26,14 @@ export interface ImageStyle {
|
|||||||
url: string
|
url: string
|
||||||
width: string
|
width: string
|
||||||
height: string
|
height: string
|
||||||
|
size: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SpreeProductImage extends JsonApiDocument {
|
export interface SpreeProductImage extends JsonApiDocument {
|
||||||
attributes: {
|
attributes: {
|
||||||
|
position: number
|
||||||
|
alt: string
|
||||||
|
original_url: string
|
||||||
styles: ImageStyle[]
|
styles: ImageStyle[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,19 @@ import { SpreeProductImage } from '../types'
|
|||||||
import getImageUrl from './get-image-url'
|
import getImageUrl from './get-image-url'
|
||||||
|
|
||||||
const createGetAbsoluteImageUrl =
|
const createGetAbsoluteImageUrl =
|
||||||
(host: string) =>
|
(host: string, useOriginalImageSize: boolean = true) =>
|
||||||
(
|
(
|
||||||
image: SpreeProductImage,
|
image: SpreeProductImage,
|
||||||
minWidth: number,
|
minWidth: number,
|
||||||
minHeight: number
|
minHeight: number
|
||||||
): string | null => {
|
): string | null => {
|
||||||
const url = getImageUrl(image, minWidth, minHeight)
|
let url
|
||||||
|
|
||||||
|
if (useOriginalImageSize) {
|
||||||
|
url = image.attributes.original_url || null
|
||||||
|
} else {
|
||||||
|
url = getImageUrl(image, minWidth, minHeight)
|
||||||
|
}
|
||||||
|
|
||||||
if (url === null) {
|
if (url === null) {
|
||||||
return null
|
return null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user