Skip to content

[Bug] MarkText cannot display images on a file share, all images show up as "Load image failed" #4577

Open

Description

@spongyryno

Description

When viewing markdown files with local images, it works when you're on a local drive, but not when the markdown is on a file share, such as \\server\share\folder.

Steps to Reproduce

Create a simple markdown file containing nothing but:

![image](foo.png)

Now, in the same folder, create an image called foo.png. Now, view it in MarkText. It works.

Now, copy both to a file share, such as \\server\share\folder

View the markdown file there. You will see it fails to load the image, and instead displays "Load image failed".

This is 100% reproducible, and works when you map a drive letter to the share instead (which isn't an option), but it preventing me from using MarkText, as every single markdown file we use is on file shares, and every one of them has images.

Expected Behavior

If MarkText can read the .md file, it should be able to read relative path image files, too, regardless of where they are.

Actual Behavior

Image displayed when the markdown is on a local drive, and an error when on a file share.

Screenshots / Logs

No response

Operating System

Windows

MarkText Version

0.19.1

OS Version

Windows 11 Pro, 10.0.26200 Build 26200

Reproducibility

  • I can reliably reproduce this issue

Activity

  1. added
    🐛 bug
    🐳 help wanted
    on Jun 24, 2026
  2. jyte commented on Jun 27, 2026

    @jyte

    Likely same as what is described in #4563 as use case 1.

    I have a fix for it that I will propose soon.

  3. Renakoni commented on Jun 28, 2026

    @Renakoni
    Contributor

    This appears to be a general UNC-path handling issue, not a WSL-only problem.

    There are two related failure modes:

    1. Relative images under UNC paths can be converted to invalid file:// URLs.
    2. Directory watching on UNC roots may not emit the initial add / addDir events unless polling is enabled.

    For example, a Windows UNC path such as:

    \\wsl.localhost\Ubuntu-24.04\home\me\docs\img\my_image.png
    \\server\share\docs\img\my_image.png
    

    must be represented as a host-based file URL:

    file://wsl.localhost/Ubuntu-24.04/home/me/docs/img/my_image.png
    file://server/share/docs/img/my_image.png
    

    The previous path resolution could lose the UNC host portion. In particular, resolving a path like:

    //wsl.localhost/Ubuntu-24.04/home/me/docs
    

    could turn it into:

    /wsl.localhost/Ubuntu-24.04/home/me/docs
    

    That then becomes:

    file:///wsl.localhost/Ubuntu-24.04/...
    

    which points to a local /wsl.localhost/... path instead of treating wsl.localhost as the file URL host.

    The fix is to preserve UNC semantics when resolving image paths and to generate normalized local file URLs:

    \\host\share\path  -> file://host/share/path
    C:\path\file.png   -> file:///C:/path/file.png
    /tmp/file.png      -> file:///tmp/file.png
    

    The project tree issue has a separate but related UNC watcher cause. On a real WSL UNC path, chokidar did not enumerate initial files with polling disabled:

    usePolling: false -> 0 events, 0 markdown files
    usePolling: true  -> events emitted, markdown files discovered
    

    So UNC roots should force usePolling: true for the watcher. This covers both WSL UNC paths such as:

    \\wsl.localhost\Distro\...
    

    and ordinary Windows network shares such as:

    \\server\share\...
    
  4. added
    🐹 platform/windows
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐹 platform/windows🐳 help wanted🐛 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions