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

Created on 28 Feb 2020  路  4Comments  路  Source: DylanVann/react-native-fast-image

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

Most helpful comment

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

All 4 comments

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.

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"]

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

Any update on defaultSource props for library?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OmarBasem picture OmarBasem  路  3Comments

jslok picture jslok  路  3Comments

pehagg picture pehagg  路  3Comments

NgocNamFNT picture NgocNamFNT  路  3Comments

mschipperheyn picture mschipperheyn  路  3Comments