TomSawyer
TomSawyer

Reputation: 3820

How to pull old UIImage from cache with SDWebImage and put it to placeholder?

I have 2 lists of images with 2 different size.

One is thumbnail images (already cached by SDWebImage).

One is original images, these images will be loaded when user tap to view detail cell.

The question is I want to put thumbnail image as a placeholder with SDWebImage.

There is a function to do it:

cell.image.sd_setImageWithURL(NSURL(string:orgimgurl!), placeholderImage: UIImage())

However, how to pull and set UIImage as a placeholderImage from cache it its exist?

Upvotes: 0

Views: 891

Answers (1)

Rahul Katariya
Rahul Katariya

Reputation: 3628

One way is that you can pass the thumbnail image to the detailView and then use it in the parameter when loading original image.

Or Try

NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url];
UIImage *cachedImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key];

Upvotes: 1

Related Questions