Skip to content

Commit f611d5e

Browse files
committed
Merge pull request SDWebImage#1188 from bill350/master
Add an option called "SDWebImageAvoidAutoImageFill" to avoid automati…
2 parents ef57824 + 4d6693c commit f611d5e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

SDWebImage/SDWebImageManager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
8282
* Use this flag to transform them anyway.
8383
*/
8484
SDWebImageTransformAnimatedImage = 1 << 10,
85+
86+
/**
87+
* By default, image is added to the imageView after download. But in some cases, we want to
88+
* have the hand before setting the image (apply a filter or add it with cross-fade animation for instance)
89+
* Use this flag if you want to manually set the image in the completion when success
90+
*/
91+
SDWebImageAvoidAutoSetImage = 1 << 11
8592
};
8693

8794
typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL);

SDWebImage/UIImageView+WebCache.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
5454
if (!wself) return;
5555
dispatch_main_sync_safe(^{
5656
if (!wself) return;
57-
if (image) {
57+
if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock)
58+
{
59+
completedBlock(image, error, cacheType, url);
60+
return;
61+
}
62+
else if (image) {
5863
wself.image = image;
5964
[wself setNeedsLayout];
6065
} else {

0 commit comments

Comments
 (0)