Skip to content

Image : Fallback image (onerrer) support #6472

@njannink

Description

@njannink

Is your feature request related to a problem? Please describe.
I want to be able to set a fallback img when loading of an image fails, eg on 404. In html you can do this by setting the onerror attribute. Currently In my own code I need to interpolate strings to be able to build the onerror attribute. Would be nice if Blazorise can do this for me.

Current onerror building

<Image Source="@ProfilePicture" onerror="@m_fallbackPicture" />

@code { 
   private string m_fallbackPicture;

   protected override void OnParametersSet()
   {
       m_fallbackPicture ??= $"this.src='{Assets.Get(@"img/DefaultAuthor.png")}'";
   }
}

Proposed Blazorise API

   <Image Source="@ProfilePicture" FallbackSource="@Assets.Get(@"img/DefaultAuthor.png")" />

Metadata

Metadata

Assignees

Labels

Type: Feature ⚙Request or idea for a new feature.

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions