-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[BUG] - fallbackSrc not working when the src image returns a 404 #4756
Comments
@ryankashi have you considered passing a height prop to the image? i think it should work after you do that |
Just tested. The way how height affects src vs. fallbackSrc are different, even if the image passed into it is the same. In addition, the height prop is improperly affecting how the image should be rendered, especially when the component itself is responsive. For example: No Height specified, via src:
No height specified, via fallbackSrc:
Height specified, via src:
No height specified, via fallbackSrc:
|
Did some additional digging. This could be due to the component not rerendering when the image should switch to the fallback source. For example, doing something like:
Will render SOMETHING, however the image itself does not fit correctly, and does not stay consistent with how it should render if it was passed directly into src. Also to note, passing in a height and width should be optional for this component as well - you shouldn't have to pass these props in just to get a fallback image to render properly Has anybody else been able to take a closer look into any of this? Thanks! |
it could be because the fallbackSrc is rendered as a background-image of the image wrapper(a div element) which in turn means that without passing a height, the div will have no content thus, have a height of 0 which makes it not visible. |
HeroUI Version
2.2.6
Describe the bug
When I try to load an image with a fallbackSrc, the image at the fallbackSrc does not load. For example:
Instead of rendering
fallbackSrc
with my fallback Image, instead the<Image/>
component will stay blank.Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Create a nextjs app and put in the following code:
This is tested both in Chrome as well as Electron
Expected behavior
The image at
/images/image_that_will_404.jpg
will return a 404 in my console. Then, the<Image/>
component should use the fallbackSrc and render this image insteadScreenshots or Videos
N/A
Operating System Version
Windows 10
Browser
Chrome
The text was updated successfully, but these errors were encountered: