getgrav / getgrav/grav-plugin-admin

Media embed in markdown fails when image filename has ":" character

Open
#2,454 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
377
Forks
225
Avg merge
11h 51m
Merged PRs (30d)
4

Description

Adding images to a grav article hits some kind of an error in the media processing or embedding when the media filename contains colon characters.

For example, I have the following screenshot images attached, with the latter being a copy of the last image but with the filename changed to remove colons:

![Image](https://github.com/user-attachments/assets/6aa43e56-7adc-427f-944c-261d70cdff27)

Using the add image button, I get the following markdown generated, respectively:

````markdown
![2025-06-29T13:36:56](2025-06-29T13:36:56.png "2025-06-29T13:36:56")
![2025-06-29T13:57:26](2025-06-29T13:57:26.png "2025-06-29T13:57:26")
![2025-06-29T14:06:44](2025-06-29T14:06:44.png "2025-06-29T14:06:44")
![2025-06-29%20030000ff](2025-06-29%20030000ff.png "2025-06-29%20030000ff")
````

However, when saved, this is the rendered HTML output:

````html
2025-06-29T13:36:56
2025-06-29T13:57:26
2025-06-29T14:06:44
2025-06-29%20030000ff
````

As you can see, there's some step, that appears to be distinct from the markdown processing, that is supposed to rewrite the `img src` attribute, that appears to fail when there's a colon character. Possibly based on the latter having %20 injected rather than space, this is expected behaviour, and it's the editor that should be adding %3A for colon instead.

But when I tried manually changing the markdown image reference to have %3A instead of the colons, that didn't fix it. And indeed you can see the parser actually reversed the URL encoding for the `src` attribute.
````markdown
![2025-06-29T14%3A06%3A44](2025-06-29T14%3A06%3A44.png "2025-06-29T14%3A06%3A44")
````
````html
2025-06-29T14%3A06%3A44
````

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start with the admin add-image button and follow the media-processing and Markdown-rendering entry points described in the report. Reproduce the issue with image filenames containing colons, compare the generated Markdown with the rendered HTML, and consider the issue done when those filenames render with the correct image source.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, php
Domain
content
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.