Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lamyseba opened this issue Jan 24, 2025 · 3 comments
Closed

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

lamyseba opened this issue Jan 24, 2025 · 3 comments
Labels
bug Something isn't working In BETA The current task is available for testing in the BETA version. Released The task has been released v10.8.0 Project: v10.8.0

Comments

@lamyseba
Copy link

lamyseba commented Jan 24, 2025

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.

@lamyseba lamyseba added the bug Something isn't working label Jan 24, 2025
@estruyf estruyf pinned this issue Feb 6, 2025
@estruyf estruyf unpinned this issue Feb 6, 2025
@estruyf estruyf moved this to In progress in v10.9.0 Feb 6, 2025
@estruyf estruyf added this to v10.9.0 Feb 6, 2025
@project-labels project-labels bot added v10.8.0 Project: v10.8.0 In progress This is actively being worked on labels Feb 6, 2025
@estruyf estruyf moved this from In progress to In beta in v10.9.0 Feb 6, 2025
@project-labels project-labels bot added the In BETA The current task is available for testing in the BETA version. label Feb 6, 2025
@estruyf
Copy link
Owner

estruyf commented Feb 6, 2025

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

@project-labels project-labels bot removed the In progress This is actively being worked on label Feb 6, 2025
@lamyseba
Copy link
Author

Thank you @estruyf , beta version works for me !

@estruyf estruyf moved this from In beta to Released in v10.9.0 Feb 27, 2025
@project-labels project-labels bot added the Released The task has been released label Feb 27, 2025
@estruyf
Copy link
Owner

estruyf commented Feb 27, 2025

Version 10.8.0 has been released

@estruyf estruyf closed this as completed Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working In BETA The current task is available for testing in the BETA version. Released The task has been released v10.8.0 Project: v10.8.0
Projects
None yet
Development

No branches or pull requests

2 participants