Skip to content

Issue: Media URLs are inserted relative to repo root instead of the public directory #354

@adam-coster

Description

@adam-coster

Describe the bug

Using the FrontMatter UI for a field with type "image", the inserted path is relative to the project root instead of "frontMatter.content.publicFolder", making it so that direct use of the image URL by my website is not possible (for the running site, the URLs are relative to the public folder, not to the repo root).

This is something in between a bug (since the current behavior is surprising and has no workaround) and a feature request (since it might currently be working as intended).

To Reproduce
Steps to reproduce the behavior:

  1. Add images to a static directory projects/site/static
  2. Set "frontMatter.content.publicFolder" to projects/site/static
  3. Add an image field to the default content-type, e.g.
{
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": false,
      "fileType": "md",
      "fields": [
        {
          "title": "Image Path",
          "name": "url",
          "type": "image",
          "isPreviewImage": true
        }
      ]
    }
  ]
}
  1. In a Markdown file, open the Front Matter sidebar and scroll to the Image Path field
  2. Click the image icon, browse for an image.
  3. Hover over the vertical '...' and click the + icon to insert the path
  4. Observe that the inserted path starts with projects/site/static

Expected behavior

I expect the "frontMatter.taxonomy.contentTypes" part of the path to be excluded from the inserted path, since all paths for the actual content are relative to the publicFolder root, not the repo root.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11 (Insiders)
  • Browser: Chrome (latest)
  • FrontMatter Version: latest of both release and beta extensions

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions