Cms: Assets "Default Upload Location" UI not working as expected

Created on 19 Apr 2018  Âˇ  24Comments  Âˇ  Source: craftcms/cms

I have an assets field setup with the following settings:
screenshot 2018-04-19 16 19 45
When you drag a file onto the field on an entry the file is uploaded into the default location as specified.
However, if you click the "Add an asset" button the UI opens up at the last location you had open. So the file will be uploaded there. I would expect the UI to open in the default location.

If you restrict the uploads to a single folder, assets functions as you'd expect, you're taken to that specified location. However, I'd like the option to pick existing files.

I understand in my path is using {id} which doesn't actually exist on a new entry, but I imagine this is just created on saving as it works when you drag in a file.

Steps to reproduce

  1. Create an assets field with a default location specified
  2. Click "Add an asset" and the default location is not opened if you've had assets open in another folder prior

Additional info

  • Craft version: 3.0.3.1
  • PHP version: 7.2.1
  • Database driver & version: MySQL 5.7.21
  • Plugins & versions: Amazon S3 1.0.8
authoring enhancement

Most helpful comment

This is now resolved for 3.4! Going forward, the first time you click “Choose an asset”, the selection modal will open up to the Default Upload Location.

There is one exception: if you have a dynamic subpath specified (e.g. news/{id}) and the folder doesn’t exist yet, then you will still get the old behavior. That’s because we don’t think it’s a good idea to start generating a bunch of dynamically-named folders automatically, if we don’t even know if you really want to upload anything to it yet, just because you clicked the “Choose an asset” button.

All 24 comments

Marking this as en enhancement request because it is currently working as intended – the setting is called “Default _Upload_ Location”, which to me doesn’t imply it will have an effect on anything besides uploading when a location isn’t specified – but I could see us potentially renaming it to “Default File Location” or something, where it also becomes the default location that the selection modal opens to, when selecting existing files.

@brandonkelly

Okay, I see what you mean. They only way the default location gets used it seems is when you drag a file onto the field and bypass the assets modal. I can't see how the default upload location is utilised via the assets modal.

It would be good to make it a feature, so by default, it would always open on the specified location you have set, yet give the user the option to upload and pick assets from elsewhere.

Basically what I'm trying to achieve is for each entry, you get a blank folder for assets. Rather than having thousands of assets in a single directory. However, still give the option for a user to pick an asset from an existing folder if they need to.

Is there another way of achieving this which you can recommend, please?

I can't see how the default upload location is utilised via the assets modal.

Yeah, it’s not, the modal will always upload to the currently-selected folder. The only other place that setting is taken into effect is when you upload files to the field from the front-end, without specifying a location.

Is there another way of achieving this which you can recommend, please?

Not at this time, sorry. But we’ll consider changing the setting name & behavior.

@brandonkelly thanks for clarifying.

Just got stuck in similar problem in related issue (aws-s3). Now it makes sense and I see what you did there and it is great, so maybe small disclaimer or a note related to Asset/cloud source could help avoid this.

I for one would love if this setting loaded the asset modal into the directory from the settings. I don't want to make it so my editors can't navigate around assets at all but I want to suggest a location for them to upload. Renaming the settings would make it clear what is actually happening but I second the FR notion of making the Asset modal load a default location.

I just ran into this issue when setting up the Default Upload Location. We want to create an organized asset structure where users' assets are uploaded to a folder for the post they are editing without restricting them from using assets from other sources.

As mentioned, only dragging a file to the asset field utilizes this setting. Most of our users click the asset field. This prevents us from automatically organizing their files.

Currently, you have to check Restrict uploads to a single folder? to ensure that asset uploads go to their intended folder. Doing so completely limits their available assets to the Upload Location.

What we want is for the uploads for an asset field to always go to a path we define, and still allow users to select assets from other sources.

Note: Referenced a Craft 2 project when writing this if that matters.

@theskyfloor Agreed but often that's not even possible, if the subfolder contains values that are pulled from the entry, but not actually known until the entry is saved.

That's true... would it be too confusing to fall back to the index when that is the case... but in circumstances of an existing entry load up the default directory. My use case is that I love keeping it simple and organized for clients but I have them re-uploading the same assets in multiple folders when I restrict it too much. Thanks!

+1 for this – we often see clients uploading to the wrong place because they just upload to whichever volume is selected when opening the modal.

Huge +1 for this. It would make asset management so much easier. At the moment you have to choose between structure (by choosing to restrict the uploads to a single folder) or flexibility (by choosing not to). This would allow for both by having a clear and consistent default location for a given Assets field, while allowing the client to select an asset from another location it if they need to.

+1 again. I've been using Craft for years and I didn't even know it was possible to drag an image to the button itself. All our clients will be clicking the "Add asset" button, and this really needs to be pre-selecting the folder in the field settings.

Clients will always put the image in whatever folder happens to be open at the time. The only way to avoid this is to force them to put assets in a single folder rather than allowing them to choose, and that restricts them, for example, to not being able to use 'blog images' in the rest of the site.

Forgive me if I'm annoying @brandonkelly, but this enhancement would go amazingly well with all the other asset-related improvements in 3.4, just sayin'. 😏

This is now resolved for 3.4! Going forward, the first time you click “Choose an asset”, the selection modal will open up to the Default Upload Location.

There is one exception: if you have a dynamic subpath specified (e.g. news/{id}) and the folder doesn’t exist yet, then you will still get the old behavior. That’s because we don’t think it’s a good idea to start generating a bunch of dynamically-named folders automatically, if we don’t even know if you really want to upload anything to it yet, just because you clicked the “Choose an asset” button.

@brandonkelly Does this also work when dragging an asset into the upload field?

Edit: Just verifying that nothing changed with drag functionality, as I believe that dragging worked as expected before.

@jsunsawyer the only thing that changed was the selected folder when opening the asset modal, so nothing changed when uploading via drag-and-drop.

Brilliant, thank you!

Sorry to dig up an old thread, the new behaviour in 3.4 is great, and goes a long way to helping with general client confusion around asset management in Craft and the difference between drag and drop and opening the asset modal. I find clients still struggle, either bad habits take over or the workflow isn't communicated to future editors, and assets end up being dragged and dropped into the root folder after opening the asset modal. I use dynamic subpaths often, especially on media heavy websites where assets need to be attributed to multiple creators or different projects.

Certainly not a good idea to generate dynamic folders on the fly before an asset is saved, but I was wondering if there was a way to go further and emulate the same behaviour of the drag and drop functionality within the asset modal, so:

  • If a dynamic subpath is set for the default upload location and the asset modal is opened, rather than the root folder being selected if the folder doesn't exist, images are uploaded to the temporary upload folder (unless the user then goes on to select a folder from the asset folder tree)
  • When the entry is saved, the folder is created based on the dynamic folder path and the assets are moved/uploaded to it.
  • When the user then visits the entry again and clicks the asset modal button, the folder exists and is opened by default.

I feel like this behaviour would really help make the workflow much clearer, with the behaviour consistent between the two upload methods.

There may be some considerations that means this isn't possible, but thought worth mentioning having found this issue today. Over the 5 or so years I've been using Craft this has probably caused me the most headaches with client sites!

Thanks for all the work, as always.

@bendesilva Good points. I don’t want to overcomplicate the selection modal UI, but I think I just came up with a good compromise: as of the next release, Assets fields will display an “Upload files” button right alongside the asset selection button, which will upload files to the field’s default upload location just like drag-n-drop uploading does.

An Assets field with the new “Upload files” button

@brandonkelly I think this is a perfect compromise. Thanks for hearing me out and coming up with a solution so quickly! This should make things a lot clearer for users rather than having to explain the drag and drop mechanism in the instructional text. Looking forward to seeing it in the next release.

Craft 3.5.12 is out now with that change ✨

Thanks Brandon!

@brandonkelly I need to voice my concern here.

Adding an "Upload Files" button next to the "+ Add an Asset" button which already uploads a file, is one of those situations where introducing choice is confusing and a step toward uncertainty and possibly even paralysis.

Given that it is possible to drag and drop an asset on the asset list dialog, I find it hard to see proportional value in adding an extra button for drag+drop functionality.

I'd rather click+see where the file will go + if it already exists, and then drag+drop vs. drag+drop blindly, hoping for the best.

When using an asset structure and working with multiple editors who end up using each others' assets, placing the images correctly has much higher value than saving a click.

If we're adding this as an optional setting, it is my hope that the default will be off as otherwise I'd have to update dozens of asset fields.

@andreimoment Those concerns have been voiced and addressed in #6954.

Was this page helpful?
0 / 5 - 0 ratings