Closed codercatdev closed 1 month ago
That's a new one. Can you share the raw public ID?
i'm having a hard time reproducing this. i tried to create a few examples, from what i can tell exactly as you have it:
<CldImage
className="h-auto w-full"
width="1920"
height="1080"
src="https://media.codingcat.dev/image/upload/v1712078330/main-codingcatdev-photo/4_firebase-security-rules.png"
alt="Mario"
priority
sizes="100vw"
/>
<CldImage
className="h-auto w-full"
width="1920"
height="1080"
src="main-codingcatdev-photo/4_firebase-security-rules.png"
alt="Mario"
priority
sizes="100vw"
/>
<CldImage
className="h-auto w-full"
width="1920"
height="1080"
src="main-codingcatdev-photo/4_firebase-security-rules"
alt="Mario"
priority
sizes="100vw"
/>
I ran decodeURIComponent on that string and it resolves an empty string, idk if that means anything
im wondering if a special character is somehow making its way into the end of src={source?.public_id}
and getting encoded there?
the only thing im actualy able to reproduce is the full URL not being properly parsed, but i think thats a separate issue and would suspect that the URL you sent isn't what's actaully being passed through, rather just the public_id as the code implies
i can at least get a fix for that. but so you're aware, if you're trying to use a cname, you need to configure it as such:
config={{
url: {
secureDistribution: 'media.codingcat.dev',
privateCdn: true
}
}}
as by default, the CldImage component uses the res.cloudinary.com
hostname
to avoid having to specify that everywhere you can create a simple wrapper similar to this, which also allows you to add "use client" so you dont have to opt the parent page into a client component: https://next.cloudinary.dev/nextjs-14#app-router-app
the cname parsing should now be fixed via https://github.com/cloudinary-community/next-cloudinary/releases/tag/v6.6.2
you still need to opt into it using the config prop, but it will work properly
okay now I finally have the steps to reproduce, trying to track it down further. It is happening when I am using draftMode not in production mode.
That was painful, it was actually sanity causing this using stega
Closing this one, here is my full example if anyone finds it.
import { stegaClean } from "@sanity/client/stega";
"use client";
import { CloudinaryAsset } from "@/sanity.types";
import { CldImage } from "next-cloudinary";
import { stegaClean } from "@sanity/client/stega";
interface CoverImageProps {
image: CloudinaryAsset;
priority?: boolean;
}
export default function CoverImage(props: CoverImageProps) {
const { image: originalImage, priority } = props;
const source = stegaClean(originalImage);
const image = source?.public_id ? (
// <Image
// className="h-auto w-full"
// width={2000}
// height={1000}
// alt={source?.alt || ""}
// src={source?.secure_url as string}
// sizes="100vw"
// priority={priority}
// />
<CldImage
className="h-auto w-full"
width={1920}
height={1080}
priority={priority}
alt={source?.context?.custom?.alt || ""}
src={source?.public_id}
config={{
url: {
secureDistribution: "media.codingcat.dev",
privateCdn: true,
},
}}
/>
) : (
<div className="bg-slate-50" style={{ paddingTop: "50%" }} />
);
return (
<div className="shadow-md transition-shadow duration-200 group-hover:shadow-lg sm:mx-0">
{image}
</div>
);
}
damn, glad you figured it out. is there anything we can do on our end to help avoid this sort of thing? im guessing no, but figured id ask if it's providing some sort of sanitization or similar
I mean you could, but it is so specific to sanity (or any preview product using stega) that I don't know if it would make sense. Not sure how widely used stega is out there.
On Tue, May 28, 2024 at 10:41 AM Colby Fayock @.***> wrote:
damn, glad you figured it out. is there anything we can do on our end to help avoid this sort of thing? im guessing no, but figured id ask if it's providing some sort of sanitization or similar
— Reply to this email directly, view it on GitHub https://github.com/cloudinary-community/next-cloudinary/issues/479#issuecomment-2135407818, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXVMKORCIRFKCGBAEMMECTZESJTPAVCNFSM6AAAAABIGYOG3SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGQYDOOBRHA . You are receiving this because you modified the open/close state.Message ID: @.*** com>
-- Alex Patterson Founder of CodingCat.dev https://codingcat.dev https://beacons.ai/codingcatdev
Bug Report
Incorrect url set
Describe the bug
Very weird encoded srcset url that is way too long
Is this a regression?
Not sure only tried the component in 14
Steps To Reproduce the error
Expected behaviour
Srcset should work
CodeSandbox or Live Example of Bug
https://github.com/codercatdev/cms-sanity/blob/add-cloudinary-components/app/(blog)/cover-image.tsx
Your environment
Additional context