-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Upload by media category #1414
base: develop
Are you sure you want to change the base?
Upload by media category #1414
Conversation
… categoryion of media category
…to media category
I have been testing with a Media category called When 'year' is selected the image is correctly added to |
It looks like the sanitizing method I've used is causing this (on line 3884 of Unfortunately |
Hmm, |
I think And thanks for checking and spotting this! |
… create a relative URL
Works are described now - the only irritation for me is in the standard media uploader, if no category is selected and am image is dragged and dropped, it results in the browser loading the image into the window. I doubt there is much that can do about that unless the code can intercept the upload but prevent it when no category is selected. |
I'll look further into that later today. |
…ploading is disabled
Latest commit should address the problem of loading the image into the browser window when uploading is disabled. It turns out that there's no need to intercept the |
Usually I upload images directly dropping to the Media Library, and not from the "Add New". |
Thanks to a If someone goes to add a file from a post, page, or text widget, then uploads the file but then does not insert it into the post, page, or widget, and then uploads a new file, any attempt to change the location for this new file will not work. What happens is that any attempt to select a new location is sent to and stored in the database, but the failure to insert the first file seems to mess up the modal itself; it continues to operate as if the location for the first file must be the correct location. If the first file is actually inserted into the post, page, or widget, everything works as intended. It also works if the page is saved or refreshed after the abortive first upload. So this is a bit of an edge case, and the fix is probably going to be hard to find, but it's where we are now. |
Still getting similar errors, sometime the category is not added, sometime it's added the one that is the default for the dropdown. |
That's disappointing! But thanks as always for checking, @xxsimoxx. I'm going to put this on the back-burner for now and come back to it again later. |
…edia from post or page
With my latest commits, I think this should work now! (I certainly hope so!) |
I'm already not getting the category assigned. Seem that this happens when I leave the dropdown unchanged. |
This PR follows PR #1403 and provides an additional option to upload a file according to media category:
If no media category has yet been created, the option is disabled with a message explaining that one needs to be created (together with a hyperlink to the place to do so):
Once that's done, a new dropdown will appear on the Add Media page, which will look like one of the following according to which uploader the user has chosen:
However, until the user has chosen a category in the dropdown, the uploader will be disabled (i.e. it will have the
inert
attribute applied to it). Once a category is chosen, this fires some JS to a new action atadmin-ajax.php
, which then registers the media category as the file destination and removes theinert
attribute from the uploader, so that it can then function as normal.When the file is uploaded to the media category folder, it will also automatically be added the media category within the admin, as will be shown by going to the List view of the media library.