for a theme i’m creating I need a possibility to upload images through the theme-settings page. No problem so far. But the images that uploaded through that specific settings page should be stored in a different dir then the standerd upload dir, or at least have something to make them different from ‘other’ media.
I did find a nice script to change the upload dir:
function ml_media_upload_dir($upload) {
global $user_ID;
if ((int)$user_ID > 0) {
$upload['subdir'] = "/" . $user_ID.'test'.$ID;
$upload['path'] .= $upload['subdir'];
$upload['url'] .= $upload['subdir'];
}
return $upload; } add_filter('upload_dir', 'ml_media_upload_dir');
By now, the upload dir is changed to a specific user_ID. But I would change the dir only when the media uploader is fired from the specific theme-options page. See screenshot below.
Would be great to get some comments on how to handle this; after searching for hours and hours still haven’t found a solution.

I think one solution could be to (temporarily) overwrite the core function with a filter. You could add the filter before the upload is initiated on your custom page, and possibly remove the filter again once it’s done.
Not tested. Good luck!