WordPress.org

Ready to get started?Download WordPress

Forums

Custom Upload Dir
Unattached images upload to 1970/01/01 (10 posts)

  1. SheerHeartAttack
    Member
    Posted 3 years ago #

    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?

    Thanks!

    http://wordpress.org/extend/plugins/custom-upload-dir/

  2. ulfben
    Member
    Plugin Author

    Posted 3 years ago #

    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?

  3. SheerHeartAttack
    Member
    Posted 3 years ago #

    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! =)

  4. ulfben
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  5. russell_10005
    Member
    Posted 3 years ago #

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

  6. mrinspire
    Member
    Posted 3 years ago #

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

    Does anyone know how to fix this please?

  7. mrinspire
    Member
    Posted 3 years ago #

    ulfben, can you please help us with this issue?

    Thanks,

    mrinspire

  8. alx359
    Member
    Posted 2 years ago #

    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'];
    }
  9. ulfben
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  10. alx359
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic