Skip to content

Extra parameters being added to frontmatter urls #7421

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

Open
DeaJae opened this issue Feb 27, 2025 · 0 comments
Open

Extra parameters being added to frontmatter urls #7421

DeaJae opened this issue Feb 27, 2025 · 0 comments
Labels
area: media-library type: bug code to address defects in shipped code

Comments

@DeaJae
Copy link

DeaJae commented Feb 27, 2025

Searched for similiar expanations and not found very much specific to this. Thought i'd try and report it as its baffling me to annoyance.
Hopefully this makes sense and not being an idiot and missing something i should have spotted weeks ago.

Describe the bug
When adding an image to a post, or loading an image from library, it displays fine in editor, but the preview panel adds HTML parameters which aren't visible in browser or terminal output, a example from editing the HTML element in Inspector:
<img src="/assets/images/25388715424_65480dbf18_k.jpg&ZeroWidthSpace;&ZeroWidthSpace;&ZeroWidthSpace;&ZeroWidthSpace;&zwnj;&#xFEFF;&zwj;&#xFEFF;&ZeroWidthSpace;&zwj;&ZeroWidthSpace;&zwj;&zwnj;&zwj;&zwnj;&ZeroWidthSpace;&zwnj;&zwj;&zwnj;&zwnj;&zwnj;&zwj;&ZeroWidthSpace;&#xFEFF;&zwnj;&zwj;&ZeroWidthSpace;&zwnj;&zwnj;&#xFEFF;&ZeroWidthSpace;&ZeroWidthSpace;&ZeroWidthSpace;&zwj;&ZeroWidthSpace;&zwj;&ZeroWidthSpace;&#xFEFF;&zwj;&zwj;&ZeroWidthSpace;&zwj;&ZeroWidthSpace;&zwj;&zwnj;&zwj;&zwj;&ZeroWidthSpace;&zwnj;&zwj;&zwnj;&zwnj;&zwnj;&#xFEFF;&ZeroWidthSpace;&zwj;&zwnj;&zwj;&#xFEFF;&#xFEFF;&ZeroWidthSpace;&zwj;&ZeroWidthSpace;&zwj;&zwnj;&#xFEFF;&#xFEFF;&zwnj;" role="presentation">

From the terminal running Decap server:

error: Error handling {"branch":"master","action":"getMediaFile","params":{"branch":"master","path":"assets/images/25388715424_65480dbf18_k.jpg​​​​‌‍​‍​‍‌‍‌​‌‍‌‌‌‍​‌‍​‌‌​​​‍​‍​‍‍​‍​‍‌‍‍​‌‍‌‌‌​‍‌‍​‍​‍‌‌"}}: ENOENT: no suc
h file or directory, open '[snip]\assets\images\25388715424_65480dbf18_k.jpg​​​​‌‍​‍​‍‌‍‌​‌‍‌‌‌‍​‌‍​‌‌​​​‍​‍​‍‍​‍​‍‌‍‍​‌‍‌‌‌​‍‌‍​‍​‍‌‌'

Strange that the error reporting doesn't show the ZeroWidthSpace, but I guess its sanitizing its output like browsers do?

To Reproduce

  1. Create a new post
  2. Add a image
  3. Look at preview window
  4. Inspect the image, see console error.

Expected behavior
The image appears in the preview window and no errors present in console or terminal

Screenshots
issue image
Applicable Versions:

  • Decap CMS version: 3.0.0

  • Git provider: Github, but local with Decapserver running.

  • OS: Windows 10/11

  • Browser version Chome/Firefox

  • Node.JS version: 18.18.2

CMS configuration

# when using the default proxy server port
local_backend: true

backend:
  name: github
  repo: DeaJae/[repo-name] # Path to your GitHub repository
  # optional, defaults to master
  # branch: main
site_url: http://localhost:8080/
# publish_mode: editorial_workflow
media_folder: "/assets/images/"
public_folder: "/assets/images/"

collections: # A list of collections the CMS should be able to edit
  - name: 'posts' # Used in routes, ie.: /admin/collections/:slug/edit
    label: 'Posts' # Used in the UI
    label_singular: 'Post' # Used in the UI, ie: "New Post"
    description: >
      The description is a great place for tone setting, high level information, and editing
      guidelines that are specific to a collection.
    folder: 'posts'
   # slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
  #  slug: '{{slug}}'
    summary: '{{title}} -- {{year}}/{{month}}/{{day}}'
    create: true # Allow users to create new documents in this collection
  #  path: '{{slug}}'
    editor:
      visualEditing: true
    view_filters:
      - label: Posts With Index
        field: title
        pattern: 'This is post #'
      - label: Posts Without Index
        field: title
        pattern: front matter post
      - label: Drafts
        field: draft
        pattern: true
    view_groups:
      - label: Year
        field: date
        pattern: \d{4}
      - label: Drafts
        field: draft
 
    fields: # The fields each document in this collection have
      - { label: 'Title', name: 'title', widget: 'string', tagname: 'h1' }
      - { label: 'Draft', name: 'draft', widget: 'boolean', default: false }
      - {
          label: 'Publish Date',
          name: 'date',
          widget: 'datetime',
          format: 'YYYY-MM-DD',
          default: '{{now}}',
        }
      - { label: "Permalink", name: "permalink", widget: "string", default: "{{slug}}" }
      - label: 'Cover Image'
        name: 'hero'
        widget: 'image'
        media_folder: '/assets/images'
        public_folder: '/assets/images'
        required: false
        tagname: ''
      - {label: "tags", name: "tags", widget: "list", default: ["posts"]}
      - { label: 'Body', name: 'body', widget: 'markdown', hint: 'Main content goes here.' }

Additional context
I had lots of trouble following the config guide, but eventually got image library paths and fields working correctly.
Tested frontmatter fields being quoted, unquoted, changed paths, all resulted in the same issue.

@DeaJae DeaJae added the type: bug code to address defects in shipped code label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: media-library type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants