Issue: Image metadata is lost when moving image to a different folder #493

Closed
opened 2026-10-05 02:50:02 +02:00 by adam · 8 comments
Owner

Describe the bug
When moving an image with metadata from one folder into another, its metadata is lost in mediaDb.json.

mediaDb.json before moving:

{
    ".frontmatter": {
        "assets": { "media": { "image.png": { "caption": "caption", "alt": "alt", "title": "title" } } }
    }
}

mediaDb.json after moving to new folder:

{ 
    ".frontmatter": {
        "assets": { "media": { "new": { "image.png": {} } } }
    } 
}

To Reproduce
Steps to reproduce the behavior:

  1. Upload an image into a media folder.
  2. Add metadata (alt text, caption).
  3. Move the image in VSCode file browser to a different folder.
  4. Open mediaDb.json — new image location is updated in mediaDb.json, but all metadata is lost.

Expected behavior
When moving an image with metadata in VS Code file browser to another folder, image metadata should be retained in mediaDb.json.

**Describe the bug** When moving an image with metadata from one folder into another, its metadata is lost in `mediaDb.json`. ` mediaDb.json` before moving: ``` { ".frontmatter": { "assets": { "media": { "image.png": { "caption": "caption", "alt": "alt", "title": "title" } } } } } ``` ` mediaDb.json` after moving to `new` folder: ``` { ".frontmatter": { "assets": { "media": { "new": { "image.png": {} } } } } } ``` **To Reproduce** Steps to reproduce the behavior: 1. Upload an image into a media folder. 2. Add metadata (alt text, caption). 4. Move the image in VSCode file browser to a different folder. 5. Open `mediaDb.json` — new image location is updated in `mediaDb.json`, but all metadata is lost. **Expected behavior** When moving an image with metadata in VS Code file browser to another folder, image metadata should be retained in `mediaDb.json`. <!-- github-sync-id:1858081202 -->
adam closed this issue 2026-10-05 02:50:02 +02:00
Author
Owner

Thanks, @polynook for opening an issue. I need to think about a way to re-map the media files and their metadata.

Thanks, @polynook for opening an issue. I need to think about a way to re-map the media files and their metadata. <!-- github-comment-id:1719330282 -->
Author
Owner

There was an issue in the move file listener. This will be fixed in the upcoming beta.

I also added a new unmapped files feature. When editing a file's metadata, a check will be performed against the metadata, which is not linked to any file with the same filename.

In the following recording you can see the updates:

  1. The new unmapped media feature
  2. The update which should happen on moving files (fixed)

https://github.com/estruyf/vscode-front-matter/assets/2900833/9d8996a8-f4f7-4c5f-9028-aa609941b33b

There was an issue in the move file listener. This will be fixed in the upcoming beta. I also added a new unmapped files feature. When editing a file's metadata, a check will be performed against the metadata, which is not linked to any file with the same filename. In the following recording you can see the updates: 1. The new unmapped media feature 2. The update which should happen on moving files (fixed) https://github.com/estruyf/vscode-front-matter/assets/2900833/9d8996a8-f4f7-4c5f-9028-aa609941b33b <!-- github-comment-id:1719652035 -->
Author
Owner

Thanks for improvements, @estruyf.

I've been testing them and the unmapped media feature seems to work great, but the metadata is not being moved in my case.

https://github.com/estruyf/vscode-front-matter/assets/71569839/53f37282-5ca7-4482-9e6e-9bde28749765

After checking the mediaDb.json before and after moving the file, the mediaDb.json remains unchanged — no entry is deleted nor added. I have to use the unmapped media feature for the changes to be reflected in the mediaDb.json.

Thanks for improvements, @estruyf. I've been testing them and the unmapped media feature seems to work great, but the metadata is not being moved in my case. https://github.com/estruyf/vscode-front-matter/assets/71569839/53f37282-5ca7-4482-9e6e-9bde28749765 After checking the `mediaDb.json` before and after moving the file, the `mediaDb.json` remains unchanged — no entry is deleted nor added. I have to use the unmapped media feature for the changes to be reflected in the `mediaDb.json`. <!-- github-comment-id:1721124654 -->
Author
Owner

Thanks @polynook for testing. It's good to see that at least the remapping works. ☺️

I will have to check if it would have anything to do with VSCode listeners on Windows.

Thanks @polynook for testing. It's good to see that at least the remapping works. ☺️ I will have to check if it would have anything to do with VSCode listeners on Windows. <!-- github-comment-id:1721144702 -->
Author
Owner

Just to add a bit more context, I'm running Front Matter inside a Debian 11 dev container in WSL 2. Maybe it'll be helpful.

Just to add a bit more context, I'm running Front Matter inside a Debian 11 dev container in WSL 2. Maybe it'll be helpful. <!-- github-comment-id:1721161607 -->
Author
Owner

Think I know what can cause it, should be fixed in the next beta.

Think I know what can cause it, should be fixed in the next beta. <!-- github-comment-id:1721163966 -->
Author
Owner

Beta has been released.

Beta has been released. <!-- github-comment-id:1721314014 -->
Author
Owner

Phenomenal work, @estruyf! Works well now. Thanks.

Phenomenal work, @estruyf! Works well now. Thanks. <!-- github-comment-id:1721335521 -->
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#493