浏览代码

Merge pull request #1384 from woolie/master

Added support for local files to KFImage.
Wei Wang 6 年之前
父节点
当前提交
1c1e1b3f44
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Sources/SwiftUI/KFImage.swift

+ 1 - 1
Sources/SwiftUI/KFImage.swift

@@ -75,7 +75,7 @@ public struct KFImage: SwiftUI.View {
     /// - Parameter options: The options should be applied when loading the image.
     /// - Parameter options: The options should be applied when loading the image.
     ///                      Some UIKit related options (such as `ImageTransition.flip`) are not supported.
     ///                      Some UIKit related options (such as `ImageTransition.flip`) are not supported.
     public init(_ url: URL?, options: KingfisherOptionsInfo? = nil) {
     public init(_ url: URL?, options: KingfisherOptionsInfo? = nil) {
-        let source = url.map { Source.network($0) }
+		let source: Source? = url.map { $0.isFileURL ? Source.provider(LocalFileImageDataProvider(fileURL: $0)) : Source.network($0) }
         self.init(source: source, options: options)
         self.init(source: source, options: options)
     }
     }