0

Can uploaded video goes to video folders? I don't want it to store in images folder.

It will store in dedicated folder.

1 Answer 1

0

I assume "images" folder is wp-content/uploads.

It is possible to store videos in seperate folder. You can use "upload_dir" filter like in example code below.

add_filter( 'upload_dir', 'some_prefix_upload_dir', 10, 1 );
function some_prefix_upload_dir( $uploads ) {
    
    if ( isset( $_FILES['async-upload']['type'] ) ) {
        
        // not sure if every video format have "video" keyword in its type
        // you can use some whitelist array of types...
        if ( false !== strpos( $_FILES['async-upload']['type'], 'video' ) ) {

            $base_dir = WP_CONTENT_DIR . '/videos';
            $base_url = content_url() . '/videos';

            $uploads['path']    = $base_dir . $uploads['subdir'];
            $uploads['url']     = $base_url . $uploads['subdir'];
            $uploads['basedir'] = $base_dir; 
            $uploads['baseurl'] = $base_url; 
        }
    }

    return $uploads;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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