Support » Plugins and Hacks » [Plugin: Custom Upload Dir] Unattached images upload to 1970/01/01

[Plugin: Custom Upload Dir] Unattached images upload to 1970/01/01

  • I just installed the plugin to use for uploading images into folders by date (rather than just month) and it works great. The only problem is that images which are uploaded directly into the Media Library, as opposed to being uploaded from the post edit page, are placed into a folder titled 1970/01/01. I assume this is because the properly-dated image folders are chosen based on the date of the post, rather than the current date — but is there a way to make new uploads use the current date? At least for unattached images?



Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author ulfben


    I’ve never tried to upload anything without a post to attach it to. I’ll have to look into that for the next release.

    Would you mind sharing your use case? Eg. why does anyone upload non-post related files to a blog?

    I’ve done it to include header images in a post which uses a gallery. If the image is attached to the post, the image will show up both at the top of the post and in the gallery. We also include photos on our author bio pages, and there’s not a way to upload into that (it just pulls from the user profile). I think there have been some other cases too, but those are the first that come to mind.

    Thank you! =)

    Plugin Author ulfben


    Sure. In the first case I’ve always opted to use the gallery exclude=”” parameter, but I know that wasn’t available (without plugins) a couple of release ago.

    I’ll have to figure out some reasonable defaults for some of the post-exclusive path components, or perhaps add a second field controlling uploads without post relation.

    Anyway, I’ll make sure to test the “stand alone” Media Gallery properly in the future. Thanks for bringing it to my attention.

    Unattached images upload to 1970/01/01. please solve this problem!

    My files also keep getting uploaded to 1970/01/01

    Does anyone know how to fix this please?

    ulfben, can you please help us with this issue?



    Try this:

    in custom_upload_dir.php\custom_upload_dir.php ~li 92:

    if($want_year || $want_month || $want_day){ //make sure the post date has been set.
    	if($post->post_status == 'auto-draft' || $post->post_date == '0000-00-00 00:00:00'){
    		return array('error' => __('Custom Upload Dir: no post date found. Please *name* & *save* the post draft before uploading.', 'cud'))
    	//[alx359] fix when loading directly from media uploader with no post/id to refer
    	//$time = strtotime($post->post_date);
    	$time = (!empty($post)) ? strtotime($post->post_date) : $_SERVER['REQUEST_TIME'];
    Plugin Author ulfben


    Thanks alx359!

    I’ve committed 3.0.2 now; it includes your fix and a fix to the author name that never worked properly.

    Please try it out and let me know if there’s problems.

    Thank to you, ulfben, for sharing this useful plugin with us!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Custom Upload Dir] Unattached images upload to 1970/01/01’ is closed to new replies.