Skip to content

Commit

Permalink
Merge pull request #2 from strapi/chore/strapiImage
Browse files Browse the repository at this point in the history
Update: function
  • Loading branch information
Mcastres authored Sep 25, 2024
2 parents c078226 + 075c7b5 commit c14760d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion next/components/ui/animated-tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
useMotionValue,
useSpring,
} from "framer-motion";
import { strapiImage } from "@/lib/strapi/strapiImage";

export const AnimatedTooltip = ({
items,
Expand Down Expand Up @@ -82,7 +83,7 @@ export const AnimatedTooltip = ({
onMouseMove={handleMouseMove}
height={100}
width={100}
src={`http:localhost:1337${item.image.url}`}
src={strapiImage(item.image.url)}
alt={item.image.alternativeText}
className="object-cover !m-0 !p-0 object-top rounded-full h-14 w-14 border-2 group-hover:scale-105 group-hover:z-30 border-white relative transition duration-500"
/>
Expand Down
8 changes: 8 additions & 0 deletions next/lib/strapi/strapiImage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { unstable_noStore as noStore } from 'next/cache';

export function strapiImage(url: string): string {
noStore();
if (url.startsWith("/")) {

if (!process.env.NEXT_PUBLIC_API_URL && document?.location.host.endsWith(".strapidemo.com")) {
return `https://${document.location.host.replace("client-", "api-")}${url}`
}

return process.env.NEXT_PUBLIC_API_URL + url
}
return url
Expand Down

0 comments on commit c14760d

Please sign in to comment.