Przeglądaj źródła

use originalData in favour of image

If originalData is available it will be used in favour of the supplied
image to store to the cache.

This will omit compressing the image in case of a JPEG.
Andy Jacobs (REVOLVER) 10 lat temu
rodzic
commit
c9ad93dd0f
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3 3
      Kingfisher/ImageCache.swift

+ 3 - 3
Kingfisher/ImageCache.swift

@@ -187,9 +187,9 @@ public extension ImageCache {
                 
                 let data: NSData?
                 switch imageFormat {
-                case .PNG: data = UIImagePNGRepresentation(image)
-                case .JPEG: data = UIImageJPEGRepresentation(image, 1.0)
-                case .GIF: data = UIImageGIFRepresentation(image)
+                case .PNG: data = originalData ?? UIImagePNGRepresentation(image)
+                case .JPEG: data = originalData ?? UIImageJPEGRepresentation(image, 1.0)
+                case .GIF: data = originalData ?? UIImageGIFRepresentation(image)
                 case .Unknown: data = originalData ?? UIImagePNGRepresentation(image.kf_normalizedImage())
                 }