|
@@ -431,15 +431,26 @@ const sliceImage = (urlString: string, width: number, height = width) => {
|
|
|
const extractedString = urlString.replace(/^https?:\/\/[^/]+/, '')
|
|
|
const resizedImageUrl = `https://mediahub.promocollection.com.au/fit-in/${width}x${height}${extractedString}`
|
|
|
return resizedImageUrl
|
|
|
+ } else {
|
|
|
+ return ''
|
|
|
}
|
|
|
}
|
|
|
+const formatURL = (url: string) => {
|
|
|
+ console.log(url, 'url')
|
|
|
+ return url.length
|
|
|
+ ? url
|
|
|
+ .replace('.JPG', '.jpg')
|
|
|
+ .replace('.PNG', '.png')
|
|
|
+ .replace('.JPEG', '.jpeg')
|
|
|
+ : ''
|
|
|
+}
|
|
|
|
|
|
const mainPicture = computed(() => {
|
|
|
if (
|
|
|
Array.isArray(productInfo.product_image) &&
|
|
|
productInfo.product_image.length
|
|
|
) {
|
|
|
- return productInfo.product_image[0]
|
|
|
+ return formatURL(productInfo.product_image[0] || '')
|
|
|
}
|
|
|
return ''
|
|
|
})
|
|
@@ -448,7 +459,7 @@ const mainPicture2 = computed(() => {
|
|
|
Array.isArray(productInfo.product_image) &&
|
|
|
productInfo.product_image.length
|
|
|
) {
|
|
|
- return sliceImage(productInfo.product_image[0], 1000)
|
|
|
+ return formatURL(sliceImage(productInfo.product_image[0], 1000))
|
|
|
}
|
|
|
return ''
|
|
|
})
|
|
@@ -457,7 +468,7 @@ const otherPicture = computed(() => {
|
|
|
Array.isArray(productInfo.product_image) &&
|
|
|
productInfo.product_image.length > 1
|
|
|
) {
|
|
|
- return productInfo.product_image.slice(1)
|
|
|
+ return productInfo.product_image.slice(1).map((i:string) => formatURL(i))
|
|
|
}
|
|
|
return []
|
|
|
})
|
|
@@ -468,7 +479,7 @@ const otherPicture2 = computed(() => {
|
|
|
) {
|
|
|
return productInfo.product_image
|
|
|
.slice(1)
|
|
|
- .map((i: string) => sliceImage(i, 1000))
|
|
|
+ .map((i: string) => formatURL(sliceImage(i, 1000)))
|
|
|
}
|
|
|
return []
|
|
|
})
|