Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is there a simple way to automatically assign a folder for media for a content node? So, if a user is editing an item (for instance id 21), the media picker will select images/21 by default?
Since the id of a media folder is given "sequencially" when created and thereby can't be identical to the id of the content node the exact scenario is not possible.
But it would be possible if you made an action handler that would automatically
In this example you need to have a property on the content node where Umbraco will store the ID of the media folder after creation of the content node.
If you wanted to be able to edit the saved folder ID you could use the a Media Picker datatype (eventually only accepting folders).
Now the folder has been created, and images can be added afterwards and will be automatically shown in front.
I hope this make sense and fits your needs.
Thanks for the reply.
I didn't mean the folder Id, but the name. Now I think about it, the name of the main item we're editing would be good for a folder name. So, if we're editing an item with a name of "Odense", when we click on "+" to add an image, instead getting Media / + in the "Select Media dialog, we would have Media / Odense / + (after the mediaResource.addFolder had been called if necessary).
I think I can do most of it - I was thinking of copying the MediaPickerController and at the start, adding the folder - I'm just not sure how to get the item name into my copy of the controller.
This is exactly what happens if you do as suggested:
I just forgot to mention that you - in the first step of the action handler - need to save the media folder with the same name as the content node (that is initiating the action handler).
Then the Media dialog of the content node will open up "inside" the selected media folder Media / Name of folder / + and the user can select images ... or images uploaded to this folder would automatically be shown if picking is not needed.
Remember that the media folder name will not be accessible as physical folder on the server since all images are being saved individually in folders with an ID. The media folder name visible in the Media section (and Media Picker) is only saved in the database.
If I'm not getting it right please correct me ;-)
Thank you for your help.
I went with a slightly different solution, where we dynamically generate a folder based on the node name, if it's not already present, and set umbLastOpenedMediaNodeId to the folder.
I'm going to see if I can get the client to release the code. There's a few things this has got me thinking about with regards to the backoffice and images.
Good that you found a solution that works. Would be interesting if your code could contribute to even better automatic workflows.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted