react-native-fast-image icon indicating copy to clipboard operation
react-native-fast-image copied to clipboard

how we show placeholder in react-native-fast-image

Open arjundalal opened this issue 4 years ago • 5 comments

Hello Team, i have fetch data from server side and display it in listview. but before loading the image i want to show the placeholder or loader image can it be possible to show the placeholder in this library. please help me to solve this issue.

Regards, Arjun Dalal

arjundalal avatar Feb 28 '20 06:02 arjundalal

I could not find anything in the code regarding a placeholder. My fix was to use absolute position to show another image on top of the fast image, and hide that view when the desired image finished loading. You can accomplish this by using the onLoad method.

In my case i was not showing a placeholder, but a progress bar, so I used the onProgress method.

Gabogg07 avatar Mar 17 '20 18:03 Gabogg07

For my case I'm using 1 placeholder for any image I load so I updated: FastImageViewConverter.java

Drawable mDefaultSource = ResourcesCompat.getDrawable(res, R.drawable.nophoto1, null);
RequestOptions options = new RequestOptions()
            .diskCacheStrategy(diskCacheStrategy)
            .onlyRetrieveFromCache(onlyFromCache)
            .skipMemoryCache(skipMemoryCache)
            .priority(priority)
            .placeholder(mDefaultSource);

and FFFastImageView.m - (void)downloadImage:(FFFastImageSource *) source options:(SDWebImageOptions) options { __weak typeof(self) weakSelf = self; // Always use a weak reference to self in blocks [self sd_setImageWithURL:_source.url placeholderImage:[UIImage imageNamed:@"noPhoto1.png"]

RuairiOliver avatar Mar 19 '20 14:03 RuairiOliver

It would be a nice to have feature. Similar to defaultSource in normal Image component.

vorasudh avatar Apr 09 '20 14:04 vorasudh

Any update on defaultSource props for library?

KPS250 avatar Oct 17 '20 05:10 KPS250

i didn see any update/merge about placeholder after ~1 year used this lib

fukemy avatar Jul 27 '22 07:07 fukemy

There's 2 main ways you could implement a placeholder:

  1. defaultSource support was just merged, could use that.
  2. Could render an image behind the image you are loading.

DylanVann avatar Aug 29 '22 03:08 DylanVann

@DylanVann i want to add Add placeholder view for images not found in cache in react-native-fast-image , how to do but i did what you said but onError i am not getting any text .

Amar1Gupta avatar Sep 09 '22 10:09 Amar1Gupta