Xamarin.forms: Image.ErrorSource and Image.LoadingSource

Created on 30 Jul 2019  ·  14Comments  ·  Source: xamarin/Xamarin.Forms

API

Description

  • Don't require FileImageSource
  • Don't modify IImageViewHandler the behavior should be implementable via the various Extension methods. UWP might need to be generalized a bit better for this

In a perfect world I think we'll also add these properties to ImageSource which will let users set these values if they define an ImageSource explicitly. Currently I think that'll be way too big of an effort and I think just having it on Image/ImageButton will suffice. Even if we were to add these to ImageSource I think string properties for these values on Image/ImageButton are valid for usability reasons. The majority of users will just want to set these values directly on image/imagebutton and we can see how often the use case for adding to imagesource comes up

IImageElement

Add these to IImageElement
```C#
ImageSource LoadingSource { get; }
ImageSource ErrorSource { get; }

## ImageButton and Image
```C#
        ImageSource LoadingSource { get; }
        ImageSource ErrorSource { get; }

Button

Button also implements IImageElement but for Button just implement these explicitly and return null

Original Description

Hi,

Please add NoImage property ot the Image control which will have the image to be displayed when no image is loaded from database or https call.

For example, if a student page opened and the student has no photo on the server trhen it should look like this:

NoImage="NoPhoto.png"

Thanks,
Jassim

F100 image in-progress proposal-open reverted enhancement ➕ up-for-grabs

Most helpful comment

@StephaneDelcroix , just to make sure that I understand this proposal.

We want to show this PlaceholderImage if the Image.Source throws some exception? For example, if the URL image isn't valid or the resource can't be loaded.

@pictos Yes when no image or when the resource or http returns no image

Also, there are two things here because maybe NoImage name is misleading..

There is:

  1. Image while Loading Image Resource from Local or Http
  2. Image when no image returned from local Resource or http

Not sure if they can be one or two...

All 14 comments

should be PlaceHolder. 👍 if we can use it with blurhashes

When will support the PlaceHolderImage and LoadingImage ?

Hi @jrahma / @TingtingAn

Just curious, how do you handle this at present in your application?

I tried to look into this in order to help but I don't find this as in-built feature on Android or iOS image control.
https://developer.android.com/reference/android/widget/ImageView
https://developer.apple.com/documentation/uikit/uiimageview

@StephaneDelcroix Also, there isn't any property/method called placeholder image on iOS too. https://stackoverflow.com/questions/15234556/how-to-assign-uiimageview-placeholderimage

All I can find that even native developers either handle it in code (as it's quite simple to assign default image) or they use custom libraries to achieve this such as Glide, Picasso, AFNetworking etc.

So I feel that instead of implementing it into Xamarin Core framework, Shouldn't this be part of some external library or plugin like I mentioned above (as it appears to be customization over in-built native functionality)? What do you suggest?

@techduggu this feature is available in FFImageLoading and if they can do it then I don't think it's an issue with the standard Xamarin Image control

I believe it is always about saving the time and making things available in one place as much as possible so if Xamatin can add then then why do we need to add extra code or use thridparty controls

@jrahma - It's good to know that it's already available with FFImageLoading library.
But again, it's a third party library (similar to what I listed in my earlier comment) that serves those customized needs which native controls do not. I don't see even Google or Apple including/merging those needs to their native controls yet. I'm not sure about the reason but one thing which comes from my experience is that they want to create generic controls with properties which are sufficient for the purpose of the control and provide ways to developers to extend/customize the same to serve their business scenarios. And most of the times such business scenarios/needs are already implemented by third-party controls which helps us as a developers. But it doesn't mean that if they (third party) can do it then Google/Apple need to do the same with their framework too.

Now coming to Xamarin Forms, I am not completely aware that we are bringing those changes to the Core library which are not even supported by native controls (that's why I asked the above question to the Xamarin team). But one thing I'm aware that we are working with a goal of making Xamarin Forms awesome for everyone (either developer or customer) and if they feel that it's something of huge demand, saves time and make things available in one place, then I support your opinion!

I would like to look at this if that would be ok team ?

Could someone from the team assign me to this thanks.

@davidbuckleyni are you working on this?

@samhouts , looks like the @davidbuckleyni doesn't work on this issue. Can I work on this one?

@pictos Sure! Thanks!

@StephaneDelcroix , just to make sure that I understand this proposal.

We want to show this PlaceholderImage if the Image.Source throws some exception? For example, if the URL image isn't valid or the resource can't be loaded.

@StephaneDelcroix , just to make sure that I understand this proposal.

We want to show this PlaceholderImage if the Image.Source throws some exception? For example, if the URL image isn't valid or the resource can't be loaded.

@pictos Yes when no image or when the resource or http returns no image

Also, there are two things here because maybe NoImage name is misleading..

There is:

  1. Image while Loading Image Resource from Local or Http
  2. Image when no image returned from local Resource or http

Not sure if they can be one or two...

It will also be great if you provide a feature to make the NoImage or the PlaceHolder to accept Lottie file as Source, something like this:

<Image Placeholder="MyLottieFile" />

Thanks,
Jassim

@pictos Thank you so much for your work on this! This let us visualize and test out the functionality, and thus create a better spec for what this API should be. Once that new spec is up, we'd be happy to have you work on it again! AMAZING STUFF, @pictos !!!! You are very much appreciated. And, of course, we'd like you (and everyone else on this thread) to comment on the new spec. @PureWeen will link it here once it's available. Thank you, everyone!

Was this page helpful?
0 / 5 - 0 ratings