How is the new media caterory file system working? Is it supposed to create real directories on the file system?
I uploaded a bunch of pics and categorized them after that, but no directories are created, and the pictures are all in the uploads folder. There is a year folder that’s empty exept from a month folder, also empty.
Do I have to select a category when I upload? That would make it hard to use the multi-uploader then…
I’m sure I selected the category option in media settings before uploading anything.
Setting a media category by itself does not create real directories to which files are uploaded. It just associates a file with that media category. It is, however, possible to make your categories into real directories by taking a couple more steps.
After you have created at least one media category, you should go to Settings → Media and, under Uploading Files, select the last option there, like this:
When you next go to upload a file, you will now see a dropdown menu which will enable you to select to which media category the file(s) should be uploaded, like this:
If you want to upload different files into different categories, just upload them one by one and change your selection in between. If you want to upload several files into the same category, just select the category (or leave it as it is) and they’ll all get uploaded there.
But I still can’t get it to work. I’ve double checked everything, and uploaded a couple of more pics, after selecting a category. I also created that folder manually, and tried again. No effect, all images are still saved directly into the uploads folder.
I’ve tried both on my local installation (wamp) and on remote server with the same result.
I know the standard procedure, inactivate plugins and see what happens, so I will do that later today and let you know if it’s any conflicts.
It seems there is some error in the code. In wp-includes/functions.php, there’s this:
} elseif ( $storefolders === '3' ) {
// Generate the media category directories.
$subdir = get_option( 'media_cat_upload_folder' );
}
Now 3 is indeed the value to store uploads by category, but the option “media_cat_upload_folder” is set nowhere, and in fact should be dynamic per upload (so not an option).
No, it’s correct. That enables the user to select a media category (which is done on pages where the uploading is done, hence is in a different file) and that choice is stored in an option.
It’s kind of spooky. Without doing anything special, just clicking through my caterories, suddenly I got the message “The upload media folder has been updated.” on the library list view. At the same time the Category select box with button “Filter” showed up, it hadn’t been there before. New files uploaded is now stored correctly, in selected category folder.
Selecting (or change) category after uploading, via the library list “edit this”, doesn’t have any effect in file system though.
This happend on remote server, so I tried to replicate the situation locally. Found out that if I select a category in library “Please choose the upload media category” (the only select box I have), move te cursor and click outside the box, I got the message about media folder updated, and the select filter box appears. It seems that nothing happened more than saving the category name when I created it, the actually category folder creation happened not until now.
Before it started to work (almost) perfect, I disabled all plugins and activated standard theme (CP twentyseventeen), but nothing change, so no such conflict.
Well, I created a media category and expected all uploads to go in there (after changing the setting as indicated "organize uploads according to media category). However all uploads went into the main uploads folder (even while selecting the category). I tried several times … no cache plugin in place. When editing the image in the media lib, I see that the media category setting is empty:
Please go through the steps you have taken to upload a file to a media category. It’s impossible to troubleshoot if I don’t know how to try to replicate what you have done.
Step 1: set the option “organize uploads according to media category”
Step 2: create a media category test1
Step 3: upload a file (“test1” is the only category and thus selected) ==> files come in the main wp-upload dir, not in a “test1” subdir
Then I tested further:
create a second category
go to uploading a file but first change to that category ==> an admin notice appears
then upload the file ==> the file goes into the correct dir
Even further testing:
remove all images and media categories
create a new media cat “test3”
try to upload files in that category ==> the deleted “test1” category reappears and files are put in that “test1” folder
Ah, so it’s expecting you to positively select a category on first usage.
But you didn’t specify on which page (and if the Media Library, which view, grid or list) you uploaded your files. There are several, and they behave differently (for reasons inherited from WP).
Also, which version of CP are you using? The nightly release is using a new version of the Media Library and might already have addressed this (and the anomaly inherited from WP).
Now, in the Library submenu (where there’s also an “add new” button and category selection), the category selection doesn’t do anything and everything arrives in the first category test1:
My version of CP: 2.2.0
I’ll see if I can test the nightly version later on. Is there a howto or plugin to switch to the nightly version (WP has something like that)?
to switch to the latest nightly you install the switch to CP plugin, then you go to this link and you copy the link to latest nightly (latest .zip link) and you paste it in the advanced mode in the switch to CP plugin in the URL field. then click the button and you are set
the “Delete permanently” link in the images is no longer red, just blue (personally I think the red was better)
2 php warnings if no images are present in wp-admin/upload.php line 544: Undefined variable $author_link and Undefined variable $author.
2 css files are requested but not present in the nightly:
wp-includes/js/filepond/cp-filepond.min.css
wp-includes/js/filepond/filepond-plugin-image-preview.min.css
javascript error on the page wp-admin/upload.php :
media-grid.min.js?ver=cp_43bd8d2f:1 Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
at HTMLDocument.<anonymous> (media-grid.min.js?ver=cp_43bd8d2f:1:15442)
This prevents the “Add new” button to work (using firefox on linux).
The selection to change the upload category media now works in wp-admin/upload.php (however, why the need for an option and not transfer the value of the selected category via javascript to the media upload ?)
after uploading a file there are 2 methods of “editing” the file: click on the file in the Library and if not ok, click on the “edit more details” link in that window. Now the first window (when just clicking on an image in the Library) shows the media categories as a plain input field, while the second window (in fact editing the image as a post) shows the media categories as a selection list. It seems the first one (where the category is shown in a text field) is not ok.
Thanks for the detailed report. It’s very helpful.
Your suggestion would make users re-select their preferred media upload category on every upload. That’s completely counter to how every other upload method works. Using an option means that a user can “set it and forget it” for however long they so choose.
Your suggestion would make users re-select their preferred media upload category on every upload. That’s completely counter to how every other upload method works. Using an option means that a user can “set it and forget it” for however long they so choose.
Well, if it was a preferred (default) option, it is strange that it is present on every upload page Also it is not clear by the explanation of the setting that it is a “preferred” option either. Next to that (and this is just my personal opinion), I don’t think people will always choose the same category by default when uploading.
But still: if it is a default setting, it should be present on a Settings page somewhere (maybe where you set the setting to save into a category folder). If people then override that setting for specific uploads, it shouldn’t change the default for later uploads. Again: just my personal opinion here.
So now you’re saying that a user should have to keep going back to a settings page to change upload category before going to the page from they want to upload a file?
That’s very strange, since you wanted before to force the user to have to reset the upload category every time they want to upload a file.
Using an option, as we do, sets a preferred default. Then the dropdown on every page where uploading is possible enables a user to change that, if they wish, without having to leave the page.
Is it necessary to have the category selection on the library view? When you click the Add New-button you’ll come to the upload screen, where the selection shows up again. It’s a bit confusing, especially …
…on the library grid view, there is no category filter. The only selection is the one mentioned above.