Asset CP Folder name not updated + images lost after renaming entry or slug
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
Description
I have an asset volume which gets subfolders according to the entries through a "path/{slug}" configuration.
In a perfect world, this linking between an entry and its specific asset folder would be "fix", like through an invisible ID layer or something, instead it easily breaks:
Steps to reproduce
- Create an asset volume with a storing location that uses "{slug}"
- Create asset field using that volume and associate with channel entry type / field layout
- Create new entry, upload images to asset field
- Asset subfolder is created as expected, in CP asset manager as on file system level
- Change entry name and, accordingly, slug of entry
- Asset manager and file system will still display the old folder name
- All images in entry are „lost“, or in other word no more associated with entry
This gets even worse if you try to manually fix it by renaming the folder in the asset manager to the new slug:
Once you upload images to the re-named/re-slugged entry, the OLD asset folder with the no longer existing slug will be recreated, containing all the new uploads. How does the system "remember" the old slug and why is it still used?
Additional info
- Craft version: Craft Pro 3.5.15.1
- PHP version: 7.2.1
- Database driver & version: MySQL 5.6.38
- Plugins & versions: Redactor, Imager X
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by reproducing the asset-volume workflow with a {slug} storage path, then trace how an entry rename affects the asset folder and field association. Done means renaming an entry preserves its existing images and prevents later uploads from recreating the old slug folder.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100