Skip to content

Commit

Permalink
fix: support image src with no protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
srindom committed Aug 16, 2022
1 parent 06c7381 commit c3d795b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/modules/products/components/image-gallary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const ImageGallery = ({ images }: ImageGalleryProps) => {
>
<span className="sr-only">Go to image {index + 1}</span>
<Image
src={image.url}
src={
image.url.startsWith("//") ? `https:${image.url}` : image.url
}
layout="fill"
objectFit="cover"
className="absolute inset-0"
Expand All @@ -54,7 +56,9 @@ const ImageGallery = ({ images }: ImageGalleryProps) => {
id={image.id}
>
<Image
src={image.url}
src={
image.url.startsWith("//") ? `https:${image.url}` : image.url
}
layout="fill"
objectFit="cover"
priority={index <= 2 ? true : false}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/products/components/thumbnail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ImageOrPlaceholder = ({
}: Pick<ThumbnailProps, "size"> & { image?: string }) => {
return image ? (
<Image
src={image}
src={image.startsWith("//") ? `https:${image}` : image}
alt="Thumbnail"
layout="fill"
objectFit="cover"
Expand Down

0 comments on commit c3d795b

Please sign in to comment.