Authored by Jean-Charles SORIN

Add an option called "SDWebImageAvoidAutoImageFill" to avoid automatic image add…

…ition in UIImageView and let developer to do it himself
@@ -82,6 +82,13 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { @@ -82,6 +82,13 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
82 * Use this flag to transform them anyway. 82 * Use this flag to transform them anyway.
83 */ 83 */
84 SDWebImageTransformAnimatedImage = 1 << 10, 84 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 + SDWebImageAvoidAutoImageFill = 1 << 11
85 }; 92 };
86 93
87 typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL); 94 typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL);
@@ -54,7 +54,12 @@ static char imageURLKey; @@ -54,7 +54,12 @@ static char imageURLKey;
54 if (!wself) return; 54 if (!wself) return;
55 dispatch_main_sync_safe(^{ 55 dispatch_main_sync_safe(^{
56 if (!wself) return; 56 if (!wself) return;
57 - if (image) { 57 + if (image && (options & SDWebImageAvoidAutoImageFill) && completedBlock)
  58 + {
  59 + completedBlock(image, error, cacheType, url);
  60 + return;
  61 + }
  62 + else if (image) {
58 wself.image = image; 63 wself.image = image;
59 [wself setNeedsLayout]; 64 [wself setNeedsLayout];
60 } else { 65 } else {