-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename crossorigin to crossOrigin for greater compatibility with Image #967
Comments
Unclear on the issue here: is the |
So the main issue is when you pass the crossOrigin prop to the This behaviour is different to the native |
That is correct, however, in the special case of crossorigin and requesting of the image, this is first handled by imagePromiseFactory.jsx via the useImage hook here. By the time the image src and remaining image props are passed to the Basically, the way I noticed this was even an issue when using 'react-image' was this: my team had a situation where we needed to set an image's crossorigin to 'anonymous' (otherwise using it within a canvas would fail). Initially, I did something like:
Yet the image was still failing, which led me to discover
everything started working again 🎉 |
It works as intended, but only when using 'crossorigin'. With 'crossOrigin', it's as if you had not passed it in at all, as crossorigin is what gets used to make the image request at first (crossorigin is important when it comes to this as it determines CORS behaviour). So while crossOrigin (and remaining imgProps) do get passed to the image element later on, as you mentioned, by that point it's too late if the browser has already cached the image (particularily an issue with Chrome/Safari). This may catch people off guard switching their codebase from the native Native:
React-Image:
I'm suggesting we support both, crossorigin (currently supported) and crossOrigin (not currently supported). Sorry, I know the crossorigin attribute is quite a confusing one altogether, I'm trying my best to explain.. 😅 |
Got it. Can consider remaining the prop in an upcoming major version |
First of all thank you so much for this package, it's pretty awesome!
If we want to make the api fully compatible with the regular image element we'll need to make the component recognise when users pass in the crossOrigin prop as opposed to just crossorigin. With regular image elements in React, you'd need to pass in the attribute with the crossOrigin casing to avoid any lint errors.
Current setup can lead to confusing behaviour when one sets the crossOrigin prop but it is then ignored by react-image (happened to me, probably pretty rare as most people don't use this attribute). I fixed this by passing in the defined crossorigin prop, but either way it should accept both ideally.
The text was updated successfully, but these errors were encountered: