From b36154000722175f0c5c704b74f53901ddfb9b24 Mon Sep 17 00:00:00 2001 From: William Laverty Date: Wed, 25 Feb 2026 01:03:05 -0800 Subject: [PATCH] Skip local variant detection for remote URL images When an Image is initialized with a remote URL (http/https), skip the local filesystem variant detection (findVariants) that looks for @2x and ~dark alternatives in the assets directory. This avoids spurious 'Could not read the assets directory' warnings when using remote images. Fixes #864. --- Sources/Ignite/Elements/Image.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/Ignite/Elements/Image.swift b/Sources/Ignite/Elements/Image.swift index 799469b2b..fd2c8873c 100644 --- a/Sources/Ignite/Elements/Image.swift +++ b/Sources/Ignite/Elements/Image.swift @@ -97,13 +97,19 @@ public struct Image: InlineElement, LazyLoadable { /// - Parameters: /// - path: The user image to render. /// - description: The accessibility label to use. + /// - isRemote: Whether this is a remote URL (skips local variant detection). /// - Returns: The HTML for this element. - private func render(path: String, description: String) -> Markup { + private func render(path: String, description: String, isRemote: Bool = false) -> Markup { var attributes = attributes attributes.append(customAttributes: .init(name: "src", value: path), .init(name: "alt", value: description)) + // Remote images don't have local variants (@2x, ~dark), so skip detection. + guard !isRemote else { + return Markup("") + } + let (lightVariants, darkVariants) = findVariants(for: path) if let sourceSet = generateSourceSet(lightVariants) { @@ -139,8 +145,9 @@ public struct Image: InlineElement, LazyLoadable { if let systemImage { return render(icon: systemImage, description: description ?? "") } else if let path { + let isRemote = path.scheme == "http" || path.scheme == "https" let resolvedPath = publishingContext.path(for: path) - return render(path: resolvedPath, description: description ?? "") + return render(path: resolvedPath, description: description ?? "", isRemote: isRemote) } else { publishingContext.addWarning(""" Creating an image with no name or icon should not be possible. \