-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[JEWEL-1058] Improve DefaultImageSourceResolver #3292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlexVanGogen
wants to merge
1
commit into
JetBrains:master
Choose a base branch
from
AlexVanGogen:alexvangogen/JEWEL-1058-local-images
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[JEWEL-1058] Improve DefaultImageSourceResolver #3292
AlexVanGogen
wants to merge
1
commit into
JetBrains:master
from
AlexVanGogen:alexvangogen/JEWEL-1058-local-images
+206
−29
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13c6fcf to
4c2b75a
Compare
Collaborator
|
@AlexVanGogen can you add the release notes to the PR? |
Contributor
Author
@rock3r Done! |
rock3r
reviewed
Nov 3, 2025
.../markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/ImageSourceResolver.kt
Show resolved
Hide resolved
.../markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/ImageSourceResolver.kt
Outdated
Show resolved
Hide resolved
.../markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/ImageSourceResolver.kt
Outdated
Show resolved
Hide resolved
.../markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/ImageSourceResolver.kt
Show resolved
Hide resolved
.../markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/ImageSourceResolver.kt
Outdated
Show resolved
Hide resolved
...ore/src/test/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultImageSourceResolverTest.kt
Show resolved
Hide resolved
0819047 to
e7d7292
Compare
faogustavo
reviewed
Nov 7, 2025
.../markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/ImageSourceResolver.kt
Outdated
Show resolved
Hide resolved
e7d7292 to
2486b3b
Compare
.../markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/ImageSourceResolver.kt
Outdated
Show resolved
Hide resolved
2486b3b to
e8d7c4e
Compare
- Support absolute and relative paths - Abstract different approaches to resolve a given string - Provide an option to not log resolve failures -- we don't want to pollute logs in editor+preview mode when resolve works on each source file edit - Make `ImageSourceResolver.resolve` return null if a given string cannot be resolved. Making Coil try to render something by an obscure string can lead to unexpected behavior (exceptions at least)
e8d7c4e to
b7d189b
Compare
rock3r
approved these changes
Nov 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The default image resolver is capable of opening absolute/external URLs and image resources shipped in the JAR. For the Markdown preview plugin, we also need to resolve local paths, relative to the project root.
Changes
ImageSourceResolver.resolvereturn null if a given string cannot be resolved. Making Coil try to render something by an obscure string can lead to unexpected behavior (exceptions at least)The most default, parameterless version works exactly the same as the previous version (except that provider is a class now and its instance can be created via one of static functions)
Before
Default resolver is used; it's capable of resolving external URLs and absolute local paths. Unable to resolve relative paths. Link 1 and 3 work, links 2 and 4 don't.
After
Local images, available by the relative path, are rendered. All 4 links work.
It can still render images outside the source file's root (because the source file can be located in the project's subdirectory). It's possible to restrict resolve to only images (recursively) inside the project's directory though. Do you think it's worth it?
Release notes
New features
ImageSourceResolver.defaultwhich allows to specify built-in resolver capabilities (e.g. external URIs, .jar resources, and local images), as well as whether to log resolve issues (#3292)Note
Refactors image resolving to a capability-based, configurable resolver that can handle URIs, absolute paths, classpath resources, and optional relative paths;
resolvenow returns null when unresolved.ImageSourceResolver.resolvenow returnsString?and exposes aCompanion.create(...)factory with default capabilities.ResolveCapability(PlainUri,AbsolutePath,RelativePathInResources,RelativePath(rootDir)) to modularize resolution.DefaultImageSourceResolverfrom singleton to class; resolves via capabilities and optionally logs failures.LocalMarkdownImageSourceResolverdefault now usesImageSourceResolver.create().DefaultImageSourceResolvertests for URIs, classpath, absolute paths, missing resources, and capability gating.assertNotNulltest helper.Written by Cursor Bugbot for commit b7d189b. This will update automatically on new commits. Configure here.