Skip to content

Conversation

@AlexVanGogen
Copy link
Contributor

@AlexVanGogen AlexVanGogen commented Oct 29, 2025

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

  • Support relative paths
  • Abstract different approaches to resolve a given string. It gives the opportunity to switch different capabilities, for example, opt out of rendering external URIs
  • 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)

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.

Screenshot 2025-10-29 at 12 13 28

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?

Screenshot 2025-10-29 at 12 10 32

Release notes

⚠️ Important Changes

  • The default Markdown image resolver is now capable of resolving local images by a relative path from the source file

New features

  • [JEWEL-1058] Introduced ImageSourceResolver.default which 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; resolve now returns null when unresolved.

  • Markdown core:
    • Image resolving:
      • ImageSourceResolver.resolve now returns String? and exposes a Companion.create(...) factory with default capabilities.
      • Introduces sealed ResolveCapability (PlainUri, AbsolutePath, RelativePathInResources, RelativePath(rootDir)) to modularize resolution.
      • Refactors DefaultImageSourceResolver from singleton to class; resolves via capabilities and optionally logs failures.
      • LocalMarkdownImageSourceResolver default now uses ImageSourceResolver.create().
  • Tests:
    • Add/expand DefaultImageSourceResolver tests for URIs, classpath, absolute paths, missing resources, and capability gating.
    • Add assertNotNull test helper.

Written by Cursor Bugbot for commit b7d189b. This will update automatically on new commits. Configure here.

@AlexVanGogen AlexVanGogen requested a review from rock3r October 29, 2025 15:28
@AlexVanGogen AlexVanGogen self-assigned this Oct 29, 2025
@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1058-local-images branch 2 times, most recently from 13c6fcf to 4c2b75a Compare October 29, 2025 16:08
@rock3r
Copy link
Collaborator

rock3r commented Nov 3, 2025

@AlexVanGogen can you add the release notes to the PR?

@rock3r rock3r requested a review from faogustavo November 3, 2025 17:00
@rock3r rock3r added the Jewel label Nov 3, 2025
@AlexVanGogen
Copy link
Contributor Author

@AlexVanGogen can you add the release notes to the PR?

@rock3r Done!

@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1058-local-images branch 3 times, most recently from 0819047 to e7d7292 Compare November 4, 2025 13:20
@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1058-local-images branch from e7d7292 to 2486b3b Compare November 11, 2025 15:41
@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1058-local-images branch from 2486b3b to e8d7c4e Compare November 11, 2025 15:50
- 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)
@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1058-local-images branch from e8d7c4e to b7d189b Compare November 11, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants