• Resolved malaiac

    (@malaiac)


    Right now, the plugin has trouble picking a folder, especially for draft/pending posts which do not have a post_date_gmt set.

    Proposal :
    Replace src/ImageUploader.php:161
    $upload_dir = wp_upload_dir(date('Y/m', $this->post->post_date_gmt ? strtotime($this->post->post_date_gmt) : time()));
    By :

    if( get_option( 'uploads_use_yearmonth_folders' ) ) {
                if( strtotime( $this->post->post_date_gmt ) > 0 ) {
                    $post_time = strtotime( $this->post->post_date_gmt );
                }
                elseif( strtotime( $this->post->post_date ) > 0 ) {
                    $post_time = strtotime( $this->post->post_date );
                }
                else {
                    $post_time = time();
                }
                $upload_dir = wp_upload_dir( date( 'Y/m', $post_time ) );
            }
            else {
                $upload_dir = wp_upload_dir();
            }

    This code respect the choice of using yearmonths folder, and tries to get the best possible date from the post

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Improvement of post date management / upload folder’ is closed to new replies.