Issue: [[&mediaUrl]] placeholder in Media snippets is not relative #711

Closed
opened 2026-10-05 03:01:34 +02:00 by adam · 3 comments
Owner

Describe the bug
In media Snippets, the &mediaUrl placeHolder does not give relative path but an erroneous absolute path).

To Reproduce
This is in my frontmatter.json

"Image zoomable légendable": {
      "description": "Cliquer sur l'image l'affichera en plus grand, et affichera la légende si  elle est définie",
      "body": "{{< image src=\"[[&mediaUrl]]\" caption=\"[[legende]]\"  >}}",
      "isMediaSnippet": true,
      "fields": [
        {
          "name": "legende",
          "title": "Légende",
          "type": "string",
          "default": ""
        }
      ]
    }
  • Edited post path : workspace/content/blog/2019/André Mitton piste cyclable stationnable/index.md
  • Choosen media path: workspace/content/blog/2019/André Mitton piste cyclable stationnable/img/photo3.jpg

When I am editing my post, click on the media button, and then choose the snippets on the desired image, vs-code frontmatter inputs in my post:

{{< image src="/content/blog/2019/André%20Mitton%20piste%20cyclable%20stationnable/img/photo3.jpg" caption=""  >}}

I expected it to input

{{< image src="img/photo3.jpg" caption=""  >}}

Note: The normal "insert image" button in media view (+"button on the image) works as expected, giving relative path.

![](img/photo3.jpg")

This bug would not be very annoying if the absolute path vscode-frontmatter compute wasn't erroneous. This computation is based on filepath in my filesystem, and not based on the previewPath properties. Hugo translate filepath into an url-friendly version when generating site, and the absolute path calculation that does vs-code-frontmatter is not the same. Using a path based on previewPath (wich is supposed to work) would be less erroneous.

But what I expect and prefer, is to get a relative path as specified in the docs. Output is nicer, and I can pay attention for subdirectories of my post, so that they have url-friendly names that will not be transformed neither by Hugo, nor by vscode-frontmatter.

Device:

  • OS: Linux
  • Front Matter CMS Version : 10.7.0
  • Browser : firefox

Additional context
My content type is in "pageBundle" mode.

**Describe the bug** In media Snippets, the [[&mediaUrl]] placeHolder does not give relative path but an erroneous absolute path). **To Reproduce** This is in my frontmatter.json ``` "Image zoomable légendable": { "description": "Cliquer sur l'image l'affichera en plus grand, et affichera la légende si elle est définie", "body": "{{< image src=\"[[&mediaUrl]]\" caption=\"[[legende]]\" >}}", "isMediaSnippet": true, "fields": [ { "name": "legende", "title": "Légende", "type": "string", "default": "" } ] } ``` * Edited post path : [[workspace]]/content/blog/2019/André Mitton piste cyclable stationnable/index.md * Choosen media path: [[workspace]]/content/blog/2019/André Mitton piste cyclable stationnable/img/photo3.jpg When I am editing my post, click on the media button, and then choose the snippets on the desired image, vs-code frontmatter inputs in my post: ``` {{< image src="/content/blog/2019/André%20Mitton%20piste%20cyclable%20stationnable/img/photo3.jpg" caption="" >}} ``` I expected it to input ``` {{< image src="img/photo3.jpg" caption="" >}} ``` Note: The normal "insert image" button in media view (`+"`button on the image) works as expected, giving relative path. ``` ![](img/photo3.jpg") ``` This bug would not be very annoying if the absolute path vscode-frontmatter compute wasn't erroneous. This computation is based on filepath in my filesystem, and not based on the previewPath properties. Hugo translate filepath into an url-friendly version when generating site, and the absolute path calculation that does vs-code-frontmatter is not the same. Using a path based on previewPath (wich is supposed to work) would be less erroneous. But what I expect and prefer, is to get a relative path as specified in the docs. Output is nicer, and I can pay attention for subdirectories of my post, so that they have url-friendly names that will not be transformed neither by Hugo, nor by vscode-frontmatter. **Device:** - OS: Linux - Front Matter CMS Version : 10.7.0 - Browser : firefox **Additional context** My content type is in "pageBundle" mode. <!-- github-sync-id:2809973146 -->
adam closed this issue 2026-10-05 03:01:34 +02:00
Author
Owner

Thanks @lamyseba for opening the issue. It was related to the page bundle. I have added support for this, and you are able to try it out in the latest beta version.

https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-front-matter-beta

Thanks @lamyseba for opening the issue. It was related to the page bundle. I have added support for this, and you are able to try it out in the latest beta version. https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-front-matter-beta <!-- github-comment-id:2639454606 -->
Author
Owner

Thank you @estruyf , beta version works for me !

Thank you @estruyf , beta version works for me ! <!-- github-comment-id:2657928351 -->
Author
Owner

Version 10.8.0 has been released

Version 10.8.0 has been released <!-- github-comment-id:2687640743 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#711