Skip to content
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

Image: Add 'onError' property #3031

Closed
SelasViktoria opened this issue Jul 5, 2022 · 4 comments · Fixed by #3032 or #3040
Closed

Image: Add 'onError' property #3031

SelasViktoria opened this issue Jul 5, 2022 · 4 comments · Fixed by #3032 or #3040
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@SelasViktoria
Copy link

Describe the feature you would like to see added

I would love to be able to pass the 'onError' property through to the underlying img element of the Image component.

Is your feature request related to a problem?

No response

Describe the solution you'd like

I would like to react properly and show a fallback image if the Image component is not able to load the given image source. Right now it is only possible to show an alternative string instead, which doesn't look nice in every use case.

Describe alternatives you have considered

No response

Additional context

No response

@SelasViktoria SelasViktoria added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Jul 5, 2022
@cetincakiroglu cetincakiroglu self-assigned this Jul 5, 2022
melloware added a commit to melloware/primereact that referenced this issue Jul 5, 2022
@melloware
Copy link
Member

sorry @cetincakiroglu didn't see you assigned this to yourself already!

@cetincakiroglu cetincakiroglu removed their assignment Jul 5, 2022
@cetincakiroglu
Copy link
Contributor

sorry @cetincakiroglu didn't see you assigned this to yourself already!

It's okay, primarily I've been working on another issue thanks for your effort and fix 👍

@melloware melloware self-assigned this Jul 5, 2022
@melloware melloware added this to the 8.2.0 milestone Jul 5, 2022
melloware added a commit to melloware/primereact that referenced this issue Jul 6, 2022
@melloware melloware linked a pull request Jul 6, 2022 that will close this issue
melloware added a commit that referenced this issue Jul 6, 2022
@C0ZEN
Copy link

C0ZEN commented Dec 15, 2023

@melloware did I miss something?
Because I cannot find it in the docs, and even though I tried to use it as a parameter of the image component, or via the pt of the image, it's not working on my side (which a 410 http error).

@melloware
Copy link
Member

Hmmm Image extends HtmlSpanElement.

export interface ImageProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, 'ref' | 'pt'> {

And HtmlSpanElement has this...

    /**
     * Fires when an error occurs during object loading.
     * @param ev The event.
     *
     * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLElement/error_event)
     */
    onerror: OnErrorEventHandler;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
4 participants