{"id":2281,"date":"2007-12-04T20:35:27","date_gmt":"2007-12-04T20:35:27","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/custom-upload-dir\/"},"modified":"2022-07-26T11:39:16","modified_gmt":"2022-07-26T11:39:16","slug":"custom-upload-dir","status":"publish","type":"plugin","link":"https:\/\/mn.wordpress.org\/plugins\/custom-upload-dir\/","author":237244,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"3.4.6","stable_tag":"3.4.6","tested":"6.0.11","requires":"3.9","requires_php":"5.2","requires_plugins":"","header_name":"Custom Upload Dir","header_author":"Ulf Benjaminsson","header_description":"","assets_banners_color":"","last_updated":"2022-07-26 11:39:16","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.amazon.com\/gp\/registry\/wishlist\/2QB6SQ5XX2U0N\/105-3209188-5640446?reveal=unpurchased&filter=all&sort=priority&layout=standard&x=21&y=17","header_plugin_uri":"http:\/\/wordpress.org\/extend\/plugins\/custom-upload-dir\/","header_author_uri":"http:\/\/www.ulfbenjaminsson.com\/","rating":4.4,"author_block_rating":0,"active_installs":5000,"downloads":109606,"num_ratings":25,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"2.5":{"tag":"2.5","author":"ulfben","date":"2008-11-28 22:00:12"},"2.5.1":{"tag":"2.5.1","author":"ulfben","date":"2008-12-14 19:17:10"},"2.5.2":{"tag":"2.5.2","author":"ulfben","date":"2008-12-15 21:45:11"},"2.5.3":{"tag":"2.5.3","author":"ulfben","date":"2008-12-29 23:11:16"},"2.5.4":{"tag":"2.5.4","author":"ulfben","date":"2008-12-31 12:34:20"},"3.0":{"tag":"3.0","author":"ulfben","date":"2010-10-21 19:27:18"},"3.0.1":{"tag":"3.0.1","author":"ulfben","date":"2010-11-01 19:37:06"},"3.0.2":{"tag":"3.0.2","author":"ulfben","date":"2011-07-29 13:46:09"},"3.3":{"tag":"3.3","author":"ulfben","date":"2011-12-18 03:24:20"},"3.3.1":{"tag":"3.3.1","author":"ulfben","date":"2011-12-28 09:47:43"},"3.3.2":{"tag":"3.3.2","author":"ulfben","date":"2011-12-29 23:26:04"},"3.4":{"tag":"3.4","author":"ulfben","date":"2013-02-10 16:03:58"},"3.4.2":{"tag":"3.4.2","author":"ulfben","date":"2015-08-21 07:40:45"},"3.4.3.1":{"tag":"3.4.3.1","author":"ulfben","date":"2015-08-21 19:27:11"},"3.4.3.2":{"tag":"3.4.3.2","author":"ulfben","date":"2019-03-24 00:28:14"},"3.4.4":{"tag":"3.4.4","author":"ulfben","date":"2019-03-24 19:44:41"},"3.4.5":{"tag":"3.4.5","author":"ulfben","date":"2020-05-05 09:22:53"},"3.4.6":{"tag":"3.4.6","author":"ulfben","date":"2022-07-26 11:39:16"}},"upgrade_notice":{"3.4.4":"<p>Fixed a few PHP warnings, and removed %permalink% template as it broke drafts.<\/p>","3.4.3.2":"<p>Added support for uploads from the Gutenberg editor.<\/p>","3.4.2":"<p>Added filter, allows users to easily extend the list of tags with anything they want.<\/p>","3.4":"<p>Added %file_ext%, support for uploads from WordPress apps and fixed some errors.<\/p>","3.3.2":"<p>Removed dead code and updated to use WordPress API properly<\/p>","3.3.1":"<p>Added %post_parent% and some fixes<\/p>","3.3":"<p>Support for WordPress 3.3 and many improvements!<\/p>","3.0.2":"<p>Fixes post_author and and post_date behaviour in the media uploader.<\/p>","3.0.1":"<p><a href=\"http:\/\/wordpress.org\/support\/topic\/plugin-custom-upload-dir-fatal-error-call-to-undefined-function-get_userdata\">Fix for &quot;undefined function get_userdata()&quot;<\/a> (thanks somatic!)<\/p>","3.0":"<p>Lots of new features and more flexible interface.<\/p>"},"ratings":{"1":3,"2":1,"3":0,"4":0,"5":21},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["2.5","2.5.1","2.5.2","2.5.3","2.5.4","3.0","3.0.1","3.0.2","3.3","3.3.1","3.3.2","3.4","3.4.2","3.4.3.1","3.4.3.2","3.4.4","3.4.5","3.4.6"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":2761753,"resolution":"1","location":"plugin"},"screenshot-2.png":{"filename":"screenshot-2.png","revision":2761753,"resolution":"2","location":"plugin"}},"screenshots":{"1":"The configuration screen.","2":"Shows how the upload path corresponds to the post's timestamp."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[88,84,6655,259],"plugin_category":[50],"plugin_contributors":[78045],"plugin_business_model":[],"class_list":["post-2281","plugin","type-plugin","status-publish","hentry","plugin_tags-files","plugin_tags-media","plugin_tags-organize","plugin_tags-upload","plugin_category-media","plugin_contributors-ulfben","plugin_committers-ulfben"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/custom-upload-dir.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/custom-upload-dir\/trunk\/screenshot-1.png?rev=2761753","caption":"The configuration screen."},{"src":"https:\/\/ps.w.org\/custom-upload-dir\/trunk\/screenshot-2.png?rev=2761753","caption":"Shows how the upload path corresponds to the post's timestamp."}],"raw_content":"<!--section=description-->\n<p>WordPress allow you to put uploads in year- and month-based folders. Custom Upload Dir is more flexible. You can construct paths from variables like post title, category, post author, post date <a href=\"http:\/\/wordpress.org\/extend\/plugins\/custom-upload-dir\/screenshots\/\">and many more<\/a>.<\/p>\n\n<p>I created Custom Upload Dir ensure my file system is always mirroring the site structure. This ensures I can always find files manually when needed. It also simplifies backups and platform migrations.<\/p>\n\n<p>\/\/<em><a href=\"http:\/\/www.ulfbenjaminsson.com\">Ulf Benjaminsson<\/a><\/em><\/p>\n\n<h4>Changelog v. 3.4.6 (2020-07-17)<\/h4>\n\n<ol>\n<li>fixed a null dereference error. (<a href=\"https:\/\/wordpress.org\/support\/topic\/warning-array_key_exists-expects-parameter-2-to-be-array-null-given\/\">thanks, defotoverij<\/a>!)<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4.5 (2020-05-05)<\/h4>\n\n<ol>\n<li>added french translation (thanks, bibi699depreau!)<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4.4 (2019-03-24)<\/h4>\n\n<ol>\n<li>Fixed a few PHP warnings<\/li>\n<li>Removed the %permalink% template as it broke uploads to drafts.<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4.3.2 (2019-03-24)<\/h4>\n\n<ol>\n<li>Added support for the Gutenberg editor.<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4.2 (2015-03-16)<\/h4>\n\n<ol>\n<li>Added <a href=\"https:\/\/wordpress.org\/plugins\/custom-upload-dir\/installation\/\">filter 'cud_generate_path'<\/a> so you can easily adjust the path with any variable you want.<\/li>\n<li>Added %mime_type% to sort files by mime type<\/li>\n<li>Added %author_role% to sort files by author role.<\/li>\n<li>Coming: support for per-post-type settings. Eg: every post type can have their own rules for where to place uploads. Currently missing the admin interface. If you feel like helping out, let me know.<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4 (2013-02-09)<\/h4>\n\n<ol>\n<li>Added %file_ext% to sort by file type<\/li>\n<li>Added <a href=\"http:\/\/wordpress.org\/support\/topic\/search-and-mobile-apps-compatibility?replies=6#post-3837193\">tentative support for uploads from WordPress apps<\/a>.<\/li>\n<li>Removed setting for \"Base upload folder\" as WP core no longer exposes this<\/li>\n<li>Cleared out some PHP error on the admin page<\/li>\n<li>Fixed leaking CSS on admin page<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.3 (2011-12-18)<\/h4>\n\n<ol>\n<li>Support for WordPress 3.3<\/li>\n<li>Support for tags and categories<\/li>\n<li>Support for custom taxonomies<\/li>\n<li>Added %current_user%, %permalink%<\/li>\n<li>Added all permalink tags<\/li>\n<li>Added test-function to admin page<\/li>\n<\/ol>\n\n<p><a href=\"http:\/\/wordpress.org\/extend\/plugins\/custom-upload-dir\/changelog\/\">Older changelogs moved here.<\/a><\/p>\n\n<h3>Additional Info<\/h3>\n\n<p>Copyright (C) 2007-2019 <a href=\"https:\/\/www.ulfbenjaminsson.com\">Ulf Benjaminsson<\/a><\/p>\n\n<p>This program is free software; you can redistribute it and\/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 2 of the License, or\n(at your option) any later version.<\/p>\n\n<p>This program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.<\/p>\n\n<p>You should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Extract the <code>custom-upload-dir<\/code>-folder and transfer it to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Customize your directory structure in <code>Settings -&gt; Custom Upload Dir<\/code><\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id='how%20do%20i%20change%20base%20upload%20folder%3F'><h3>How do I change base upload folder?<\/h3><\/dt>\n<dd><p>Since WP 3.5, by a setting in wp-config.php:<\/p>\n\n<pre><code>define('UPLOADS', WP_CONTENT_DIR.'\/your-folder');\n<\/code><\/pre>\n\n<p>Just be aware that this will likely break all paths to your previously uploaded stuff.<\/p><\/dd>\n<dt id='how%20can%20i%20define%20my%20own%20tags%3F'><h3>How can I define my own tags?<\/h3><\/dt>\n<dd><p>Use the <code>cud_generate_path<\/code>-filter, like so:<\/p>\n\n<pre><code>function my_generate_path($template, $post_id){\n    $my_tags = array('%tag1%','%tag2%');\n    $replace = array($data, getData());\n    $customdir = str_replace($tags, $replace, $template);\n    return $customdir;\n}\nadd_filter('cud_generate_path', 'my_generate_path');\n<\/code><\/pre><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>Changelog v. 3.4.5 (2020-05-05)<\/h4>\n\n<ol>\n<li>added french translation (thanks, bibi699depreau!)<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4.4 (2019-03-24)<\/h4>\n\n<ol>\n<li>Fixed a few PHP warnings<\/li>\n<li>Removed the %permalink% template as it broke uploads to drafts.<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4.3.2 (2019-03-24)<\/h4>\n\n<ol>\n<li>Fixed 'upload_dir' not providing $post_id in Gutenberg editor.<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4.1 (2015-03-16)<\/h4>\n\n<ol>\n<li>Added <a href=\"https:\/\/wordpress.org\/plugins\/custom-upload-dir\/installation\/\">filter 'cud_generate_path'<\/a> so you can easily adjust the path with any variable you want.<\/li>\n<li>Added %mime_type% to sort files by mime type<\/li>\n<li>Added %author_role% to sort files by author role.<\/li>\n<li>Coming: support for per-post-type settings. Eg: every post type can have their own rules for where to place uploads. Currently missing the admin interface. If you feel like helping out, let me know.<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.4 (2013-02-09)<\/h4>\n\n<ol>\n<li>Added %file_ext% to sort by file type<\/li>\n<li>Added <a href=\"http:\/\/wordpress.org\/support\/topic\/search-and-mobile-apps-compatibility?replies=6#post-3837193\">tentative support for uploads from WordPress apps<\/a>.<\/li>\n<li>Removed setting for \"Base upload folder\" as WP core no longer exposes this<\/li>\n<li>Cleared out some PHP error on the admin page<\/li>\n<li>Fixed leaking CSS on admin page<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.3.2 (2011-12-29)<\/h4>\n\n<ol>\n<li>Updated init to use WordPress API properly<\/li>\n<li>Removed dead code<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.3.1 (2011-12-27)<\/h4>\n\n<ol>\n<li>Fixed poor sanitization of post slugs (%post_name%)<\/li>\n<li>Added %post_parent%<\/li>\n<li>Fixed settings not always initializing<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.3 (2011-12-18)<\/h4>\n\n<ol>\n<li>Support for WordPress 3.3<\/li>\n<li>Support for tags and categories<\/li>\n<li>Support for custom taxonomies<\/li>\n<li>Added %current_user%, %permalink%<\/li>\n<li>Added all permalink tags<\/li>\n<li>Added test-function to admin page<\/li>\n<\/ol>\n\n<h4>Changelog v. 3.0.2 (2011-07-29)<\/h4>\n\n<ol>\n<li>Fix for post_author not working<\/li>\n<li>Fix timestamps from the media uploader (<a href=\"http:\/\/wordpress.org\/support\/topic\/plugin-custom-upload-dir-unattached-images-upload-to-19700101?replies=8\">thanks; alx359<\/a>)<\/li>\n<\/ol>\n\n<p><strong>Changelog v. 3.0.1 (2010-11-01)<\/strong><\/p>\n\n<ol>\n<li><a href=\"http:\/\/wordpress.org\/support\/topic\/plugin-custom-upload-dir-fatal-error-call-to-undefined-function-get_userdata\">Fix for \"undefined function get_userdata()\"<\/a> (thanks somatic!)<\/li>\n<\/ol>\n\n<p><strong>Changelog v. 3.0 (2010-10-21)<\/strong><\/p>\n\n<ol>\n<li>Rewrote entire plugin for WordPress 3.0<\/li>\n<li>A slew of new placeholders for building path's with<\/li>\n<li>A new interface to allow arbitrary strings in path<\/li>\n<li>Error messages when uploading to un-named or un-dated posts<\/li>\n<li>Added translation support<\/li>\n<\/ol>\n\n<p><strong>Changelog v.2.5.4 (2008-12-31)<\/strong><\/p>\n\n<ol>\n<li>Adjusted the test case. (Pedja)<\/li>\n<\/ol>\n\n<p><strong>Changelog v.2.5.3 (2008-12-30)<\/strong><\/p>\n\n<p>More problems have crept up due to the <a href=\"http:\/\/trac.wordpress.org\/ticket\/8753\">massive amount of dry runs of 'upload_dir'<\/a> in WP 2.7.<\/p>\n\n<ol>\n<li>Added quick bail for every call that's not for a file upload. (props to Pedja Ljubomirovic (Canada))<\/li>\n<\/ol>\n\n<p><strong>Changelog v.2.5.2 (2008-12-15)<\/strong><\/p>\n\n<ol>\n<li>Fixed problem with plugin blocking deletion\/editing of attached files.<\/li>\n<\/ol>\n\n<p><strong>Changes in v.2.5.1 (2008-12-14)<\/strong><\/p>\n\n<ol>\n<li>Fixed Custom Upload Dir breaking WP 2.7 when called from the loop<\/li>\n<\/ol>\n\n<p><strong>Changes in v.2.5 (2008-11-15)<\/strong><\/p>\n\n<ol>\n<li>Support for WP 2.7-beta1<\/li>\n<li>Added 'post_author'  <\/li>\n<li>Fixed 'post_title' (broken since WP 2.4)<\/li>\n<li>Fixed issue with use_yearmonth overriding post date  <\/li>\n<li>Tons of small(ish) updates<\/li>\n<li>Removed Mediacaster-support<\/li>\n<\/ol>\n\n<p><strong>Changes in v.2.0<\/strong> (2007-10-19)<\/p>\n\n<ol>\n<li>Mediacaster compability.<\/li>\n<li>Added proper configuration screen<\/li>\n<li>Massive code overhaul<\/li>\n<li>Name change (previously \"Daily Upload Dir\")<\/li>\n<\/ol>","raw_excerpt":"Keeps your uploaded files organized in smart folder structures.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/2281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=2281"}],"author":[{"embeddable":true,"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/ulfben"}],"wp:attachment":[{"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=2281"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=2281"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=2281"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=2281"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=2281"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/mn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=2281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}