我假设;“图像”;文件夹为wp内容/上载。
可以将视频存储在单独的文件夹中。您可以使用;upload\\u dir“上传”;过滤器如下面的示例代码所示。
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;
}