Skip to content

Commit 3603070

Browse files
committed
More bug fixes
1 parent 7b75633 commit 3603070

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

Sources/ImageViewerRemote/ImageViewerRemote.swift

+4-10
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ public struct ImageViewerRemote: View {
2727

2828
loader = ImageLoader(url: imageURL)
2929
}
30-
31-
func getURLRequest(url: String) -> URLRequest {
32-
let url = URL(string: url)!
33-
var request = URLRequest(url: url)
34-
request.httpMethod = "GET"
35-
36-
return request;
37-
}
3830

3931
@ViewBuilder
4032
public var body: some View {
@@ -60,7 +52,7 @@ public struct ImageViewerRemote: View {
6052
VStack {
6153
ZStack {
6254
if(self.disableCache == nil || self.disableCache == false) {
63-
URLImage(url: URL(string: self.imageURL)!, content: { image in
55+
URLImage(url: URL(string: self.imageURL) ?? URL(string: "https://via.placeholder.com/150.png")!, content: { image in
6456
image
6557
.resizable()
6658
.aspectRatio(self.aspectRatio?.wrappedValue, contentMode: .fit)
@@ -321,7 +313,9 @@ class ImageLoader: ObservableObject {
321313
init(url: Binding<String>) {
322314
self.url = url
323315

324-
load()
316+
if(url.wrappedValue.count > 0) {
317+
load()
318+
}
325319
}
326320

327321
deinit {

0 commit comments

Comments
 (0)