grav-plugin-admin icon indicating copy to clipboard operation
grav-plugin-admin copied to clipboard

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

Open cortices opened this issue 6 months ago • 1 comments

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

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

![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:

<img src="2025-06-29T13:36:56.png" alt="2025-06-29T13:36:56" title="2025-06-29T13:36:56">
<img src="2025-06-29T13:57:26.png" alt="2025-06-29T13:57:26" title="2025-06-29T13:57:26">
<img src="2025-06-29T14:06:44.png" alt="2025-06-29T14:06:44" title="2025-06-29T14:06:44">
<img title="2025-06-29%20030000ff" alt="2025-06-29%20030000ff" src="/user/pages/03.blog/yamaha-remote-head-amp-control-a-saga-20-years-too-late/2025-06-29 030000ff.png">

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.

![2025-06-29T14%3A06%3A44](2025-06-29T14%3A06%3A44.png "2025-06-29T14%3A06%3A44")
<img src="2025-06-29T14:06:44.png" alt="2025-06-29T14%3A06%3A44" title="2025-06-29T14%3A06%3A44">

Thanks!

cortices avatar Jun 29 '25 04:06 cortices

my quick fix for you is rename your images :).. this is kinda obscure as I don't think i've ever seen a filename with : in it before.. i'm sure it's valid, just VERY uncommon. My motivation to take precious time to address this edge case is pretty low to be brutally honest.

rhukster avatar Jun 29 '25 17:06 rhukster