-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
[5.x] Dynamic asset folders #10808
[5.x] Dynamic asset folders #10808
Conversation
this would happen if you were using a folder named differently from the entry slug, then you picked another image.
Just an idea. If the folder name could be a specific field, like a date field, would be nice. |
Love this, but it would be great if it could be extended to be based on more than just the slug, for example we have needed user specific folders in the past. |
Both cool ideas! Just to play devil's advocate though...
What happens if you change the field value? Does the folder get renamed?
What happens if Alan creates the entry then Brian edits it? |
Bad wording on my part. It would be the author not the user. So whomever the author is. If it changes then I’d expect the links to need manually updated. |
One more suggestion (related to the configurable field idea): It would be great if this could also be used in user blueprints, so if you have user-specific files (eg avatars or other things a user might upload to their profile) each user gets their own folder. As users don't have slugs I think this would require the field to be configurable, so you could use their ID or email instead. |
Hmm, good question. Linked assets would loose the path, when the folders get renamed, right? |
If you renamed the folder, the entry will get updated and it'll still work. But I mean the other way. If you edit the date (or slug or whatever field the folder is named after) should the folder change? That starts to get awkward. It's already a little awkward in its current state. Once you pick a slug, that'll be the folder. If you change the slug, the folder will be out of sync. Keeping it in sync is a bit of a headache. |
Ok I've added support for doing basic stuff other than slug. You can use So for example you can do this: type: assets
folder: users
dynamic: author and if the author is Bob whose user id is 7, an uploaded image will be placed in I've intentionally restricted it to An example of more complex situation being:
|
This is wonderful, thank you |
First thanks for working on this, we needed this feature for a previous project. It would be nice to have it automatically keep the directory uptodate as it makes deleting the assets (when the entry is deleted) much easier. But I also get that this is difficult, so at the very least I would say a note in the docs would be nice to note that it will not be kept in sync. |
Digging into this further, I can see why we hadn't implemented this feature yet. 🤣 |
…er changed something
Just a random thought about keeping folders in sync. What if a folder was always created with the ID of the entry. But instead of showing the folder's actual name in the assets browser, you'd have a configurable display name that can be set to anything you'd want. So a folder's display name could be set to the entry's title. And renaming the entry wouldn't actually rename the folder but only the display name of the folder. Maybe that's a doable workaround. |
Wouldn't you need to then keep the folder title in sync with the entry title? |
Yeah, sure. But that would just happen on a metadata level. So no actual folder renaming would be done. So no need to update assets references and such. |
But this obviously doesn't solve the potentially confusing UX for users if folder names change. But it might make it easier from a technical point of view. Not sure. Just a random thought. |
This PR adds an option to the assets fieldtype so that each entry will have a dedicated folder based on the slug.
Closes statamic/ideas#725