Skip to content

Commit 40613f6

Browse files
committed
Still keep the placeholder arg, this may be useful for common usage like image name placeholder
1 parent df96e83 commit 40613f6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ public struct WebImage : View {
2626

2727
/// Create a web image with url, placeholder, custom options and context.
2828
/// - Parameter url: The image url
29+
/// - Parameter placeholder: The placeholder image to show during loading
2930
/// - Parameter options: The options to use when downloading the image. See `SDWebImageOptions` for the possible values.
3031
/// - Parameter context: A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
31-
public init(url: URL?, options: SDWebImageOptions = [], context: [SDWebImageContextOption : Any]? = nil) {
32+
public init(url: URL?, placeholder: Image? = nil, options: SDWebImageOptions = [], context: [SDWebImageContextOption : Any]? = nil) {
3233
self.url = url
3334
self.options = options
3435
self.context = context
36+
if let placeholder = placeholder {
37+
self.placeholder = AnyView(placeholder)
38+
}
3539
self.imageManager = ImageManager(url: url, options: options, context: context)
3640
// load remote image here, SwiftUI sometimes will create a new View struct without calling `onAppear` (like enter EditMode) :)
3741
// this can ensure we load the image, SDWebImage take care of the duplicated query

0 commit comments

Comments
 (0)