next-cloudinary icon indicating copy to clipboard operation
next-cloudinary copied to clipboard

[Feature] Prevent displaying broken image while image is processing

Open colbyfayock opened this issue 1 year ago • 18 comments

Feature Request

Is your feature request related to a problem? Please describe.

For some transformations like background removal and AI transformations, the first request may recieve a 423 if it needs to be processed.

The CldImage component currently polls the image until its finished and refreshes the DOM, but in the meantime, the image is displayed as broken on the page.

How can we prevent the image appearing visually broken?

Can somewhat try to replicate the way the underlaying Next Image component is handling placeholders potentially

colbyfayock avatar Sep 08 '24 02:09 colbyfayock

Hey @colbyfayock , Can you please assign this to me?

sahil9001 avatar Oct 03 '24 04:10 sahil9001

all yours! let me know if you have any questions or if anything is unclear

colbyfayock avatar Oct 03 '24 14:10 colbyfayock

Hey @colbyfayock, how do I get the removed background image? When I used the dev setup they just simply won't load, I needed it to load as I am using original image blurring so wanted to see the blue over original image

sahil9001 avatar Oct 03 '24 17:10 sahil9001

@colbyfayock Also, how do we want to proceed with this? Do we want to show the spinner or the blurred image?

sahil9001 avatar Oct 03 '24 17:10 sahil9001

@sahil9001 you need to enable the Backhround Removal Add-On within your Cloudinary account

https://cloudinary.com/documentation/cloudinary_ai_background_removal_addon

I'm open to suggestions, I was thinking of something a bit unopinionated where not everyone may want a spinner, so perhaps a blurred image would be nice, especially because you can use the original image without the background removed to achieve that

colbyfayock avatar Oct 03 '24 18:10 colbyfayock

you'd want to do this work within this function: https://github.com/cloudinary-community/next-cloudinary/blob/main/next-cloudinary/src/components/CldImage/CldImage.tsx#L99

colbyfayock avatar Oct 03 '24 18:10 colbyfayock

@sahil9001 you need to enable the Backhround Removal Add-On within your Cloudinary account

https://cloudinary.com/documentation/cloudinary_ai_background_removal_addon

I'm open to suggestions, I was thinking of something a bit unopinionated where not everyone may want a spinner, so perhaps a blurred image would be nice, especially because you can use the original image without the background removed to achieve that

That would also mean that I have to buy subscription for background removal? Because on the UI it says to buy subscription in order to use it.

sahil9001 avatar Oct 03 '24 18:10 sahil9001

it comes with 15 free removals under a free tier

colbyfayock avatar Oct 03 '24 18:10 colbyfayock

I'm open to suggestions, I was thinking of something a bit unopinionated where not everyone may want a spinner, so perhaps a blurred image would be nice, especially because you can use the original image without the background removed to achieve that

I agree with this, thanks. Raising a PR

sahil9001 avatar Oct 03 '24 18:10 sahil9001

@sahil9001 any updates?

colbyfayock avatar Oct 11 '24 15:10 colbyfayock

Sorry man, got caught up with few things here, I will do this by tomorrow.

sahil9001 avatar Oct 14 '24 16:10 sahil9001

@sahil9001 Hi! Are you insterested in working on this?

devpatocld avatar Sep 30 '25 17:09 devpatocld

Hey @devpatocld. I would like to work on this issue if no one is taking up this issue.

Vaibhav91one avatar Sep 30 '25 19:09 Vaibhav91one

@Vaibhav91one we are not assigning issues. Feel free to submit a PR but please make sure no one has submmited one for this issue alreay

devpatocld avatar Oct 02 '25 16:10 devpatocld

Hi, If no one is working on this, i would like to work on this and submit a PR! Following up on @sahil9001's work.

Pratheek2474 avatar Oct 05 '25 08:10 Pratheek2474

Hello! I am almost done but how do i test whether it is working or not? Do i make a sample page in the local install and use the changed local component 'CdImage' to see if it is working as intended?

Pratheek2474 avatar Oct 05 '25 20:10 Pratheek2474

Hi @colbyfayock @devpatocld, I have raised a PR. Please have a look at it and please let me know if any changes are required.

Vaibhav91one avatar Oct 11 '25 12:10 Vaibhav91one

@Vaibhav91one Thank you! will review as soon as we can!

devpatocld avatar Oct 13 '25 17:10 devpatocld