mirror of
https://github.com/vercel/commerce.git
synced 2025-07-05 20:51: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
|
||||
width: string
|
||||
height: string
|
||||
size: string
|
||||
}
|
||||
|
||||
export interface SpreeProductImage extends JsonApiDocument {
|
||||
attributes: {
|
||||
position: number
|
||||
alt: string
|
||||
original_url: string
|
||||
styles: ImageStyle[]
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,19 @@ import { SpreeProductImage } from '../types'
|
||||
import getImageUrl from './get-image-url'
|
||||
|
||||
const createGetAbsoluteImageUrl =
|
||||
(host: string) =>
|
||||
(host: string, useOriginalImageSize: boolean = true) =>
|
||||
(
|
||||
image: SpreeProductImage,
|
||||
minWidth: number,
|
||||
minHeight: number
|
||||
): 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) {
|
||||
return null
|
||||
|
Loading…
x
Reference in New Issue
Block a user