commerce/framework/spree/utils/createGetAbsoluteImageUrl.ts

21 lines
421 B
TypeScript

import { SpreeProductImage } from '../types'
import getImageUrl from './getImageUrl'
const createGetAbsoluteImageUrl =
(host: string) =>
(
image: SpreeProductImage,
minWidth: number,
minHeight: number
): string | null => {
const url = getImageUrl(image, minWidth, minHeight)
if (url === null) {
return null
}
return `${host}${url}`
}
export default createGetAbsoluteImageUrl