• Invalid custom image storage folder setting.

    function wpse_16722_type_upload_dir( $args ) {

    // Get the current post_id
    $id = ( isset( $_REQUEST[‘post_id’] ) ? $_REQUEST[‘post_id’] : ” );

    if( $id ) {
    // Set the new path depends on current post_type
    $newdir = ‘/’ . get_post_type( $id );

    $args[‘path’] = str_replace( $args[‘subdir’], ”, $args[‘path’] ); //remove default subdir
    $args[‘url’] = str_replace( $args[‘subdir’], ”, $args[‘url’] );
    $args[‘subdir’] = $newdir;
    $args[‘path’] .= $newdir;
    $args[‘url’] .= $newdir;
    }
    return $args;
    }
    add_filter( ‘upload_dir’, ‘wpse_16722_type_upload_dir’,9999);

    Not stored in the desired folder. .

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Invalid custom image storage folder setting’ is closed to new replies.