Jul 14 - Using CDN - update
This commit is contained in:
@@ -452,6 +452,7 @@ struct HistoryDetailView: View {
|
||||
schema: formSchema,
|
||||
formValues: savedValues
|
||||
)
|
||||
.environment(\.mediaURLByPath, inspection.mediaURLByPath)
|
||||
.padding(.horizontal, 24)
|
||||
}
|
||||
}
|
||||
@@ -928,6 +929,7 @@ struct ReadOnlyCellView: View {
|
||||
|
||||
struct PhotoThumbnailView: View {
|
||||
let value: String
|
||||
@Environment(\.mediaURLByPath) private var mediaURLByPath
|
||||
@State private var showLightbox = false
|
||||
|
||||
var body: some View {
|
||||
@@ -954,7 +956,7 @@ struct PhotoThumbnailView: View {
|
||||
.font(.system(size: 11)).foregroundStyle(.secondary)
|
||||
}
|
||||
} else if value.hasPrefix("uploads/") {
|
||||
let url = URL(string: "\(ServerConfig.current)/static/\(value)")
|
||||
let url = ServerConfig.mediaURL(absolute: mediaURLByPath[value], path: value)
|
||||
thumbnailButton {
|
||||
AsyncImage(url: url) { phase in
|
||||
switch phase {
|
||||
@@ -1042,3 +1044,19 @@ struct MailComposeView: UIViewControllerRepresentable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Media URL environment
|
||||
// Injects a {relative_path: absolute_url} map (from APIInspectionSummary.mediaURLByPath)
|
||||
// so image cells deep inside the read-only grid can resolve presigned R2 URLs
|
||||
// without threading field IDs through every layer. Empty map → the resolver
|
||||
// falls back to building a /static/ URL from the relative path.
|
||||
private struct MediaURLByPathKey: EnvironmentKey {
|
||||
static let defaultValue: [String: String] = [:]
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
var mediaURLByPath: [String: String] {
|
||||
get { self[MediaURLByPathKey.self] }
|
||||
set { self[MediaURLByPathKey.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user