Sfoglia il codice sorgente

Add two comments for memo

onevcat 1 anno fa
parent
commit
55266a43b5
1 ha cambiato i file con 2 aggiunte e 0 eliminazioni
  1. 2 0
      Sources/Image/Image.swift

+ 2 - 0
Sources/Image/Image.swift

@@ -93,12 +93,14 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
     }
     }
     
     
     var size: CGSize {
     var size: CGSize {
+        // Prefer to use pixel size of the image
         let pixelSize = base.representations.reduce(.zero) { size, rep in
         let pixelSize = base.representations.reduce(.zero) { size, rep in
             CGSize(
             CGSize(
                 width: max(size.width, CGFloat(rep.pixelsWide)),
                 width: max(size.width, CGFloat(rep.pixelsWide)),
                 height: max(size.height, CGFloat(rep.pixelsHigh))
                 height: max(size.height, CGFloat(rep.pixelsHigh))
             )
             )
         }
         }
+        // If the pixel size is zero (SVG or PDF, for example), use the size of the image.
         return pixelSize == .zero ? base.representations.reduce(.zero) { size, rep in
         return pixelSize == .zero ? base.representations.reduce(.zero) { size, rep in
             CGSize(
             CGSize(
                 width: max(size.width, CGFloat(rep.size.width)),
                 width: max(size.width, CGFloat(rep.size.width)),