Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm converting my old web project to WP and there are tons of book covers that aren't to be uploaded/managed by WP but by my own functions. Where is the right place to store such a kind of custom content? For sure it has to be a new folder but where? Maybe wp-content/uploads/cover or wp-content/cover ?

share|improve this question
    
Such a thing is arbitrary, in my opinion. I would suggest you to go for either wp-content or place them in your theme folder. –  Ivan Hanák Nov 17 '13 at 10:56
    
Exactly. I would put them in the theme folder since it seems to be dependent on the theme. –  graphical_force Nov 17 '13 at 16:37
1  
I disagree, it's far from arbitrary since it's connected to file permissions and general site set up. PS theme folder are erased on update, last place I would put anything that needs to be persistent :) –  Rarst Nov 17 '13 at 16:39
    
30k book cover images aren't theme dependent - that's for sure lol –  Hexodus Nov 17 '13 at 16:43

1 Answer 1

up vote 2 down vote accepted

WordPress has a core function wp_upload_dir that return info for the current upload folder.

Using this function you can retrieve all info on uploads folder base on current configuration.

E.g. if you set WP_CONTENT_DIR and/or WP_CONTENT_URL or UPLOADS constants that function will return the direcory according to this settings.

If you have checked the option to store media based on current month, in WordPress settings you'll get that info too.

What I suggest is to use this function and appened the folder 'cover':

$upload_info = wp_upload_dir();
$covers_path = $upload_info['basedir'] . '/cover' .  $upload_info['subdir'];
$covers_url = $upload_info['baseurl'] . '/cover' .  $upload_info['subdir'];

with standard settings, the $covers_path will be something like:

/path/to/wordpress/wp-content/uploads/covers/

if you have year/month organization turned off, or it will be something like

/path/to/wordpress/wp-content/uploads/covers/2013/11

if year/month organization is turned on.

In this way:

  • Your path became dynamic instead of hardcoded, and if you have to change you settings (e.g. domain, subdomain, WP folder...), for some reason in the future, you will have no problem
  • You can make use of the year/month organization of uploaded images, that is very useful if you have a lot of images

Additionally, as @Rarst said in comment, if content is being added from inside WP on ongoing basis, content uploads is nearly only place that is as likely to be easy to write to as possible (otherwise native uploads don't work). Pretty much any other place in WP install needs to go through filesystem API for reliable writes.

share|improve this answer
1  
Additionally, if content is being added from inside WP on ongoing basis, content uploads is nearly only place that is as likely to be easy to write to as possible (otherwise native uploads don't work). Pretty much any other place in WP install needs to go through filesystem API for reliable writes. –  Rarst Nov 17 '13 at 16:40
    
@Rarst added your comment in answer body because it worth. –  G. M. Nov 17 '13 at 16:48
    
Then wp-content seems to be the logical choice. Right now I'm using my own php/jquery wp-independent uploader but it may be a good idea to check available wp solutions. Then following wp conventions would become important. No idea so far if I can adapt them for my needs. I'm doing many automated tasks with images like centering, croping, multi-thumbnailing and color balancing so it may be a greater task... This autotasks are also used with bulk-uploads which goes without an interface. –  Hexodus Nov 17 '13 at 16:55
    
G.M. Thank you very much for your in depth explanation. So I'll follow your advice which is the most logical choice. But the month organisation isn't a great feature when it comes to handle 30k+ images. This is the first I turn off when installing wp. @Rarst Thanx for your useful comments. Since my uploader is php only I think that there will be no inteferrence with wp. But the storing location should follow the convention - why make the life harder then it should be? –  Hexodus Nov 17 '13 at 16:59
1  
@Hexodus further reading serverfault.com/questions/187187/… –  G. M. Nov 17 '13 at 17:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.