Update aliyun-oss-wordpress.php
修复使用sanitize_file_name导致BuddyPress插件页面异常的BUG,改用wp_handle_upload_prefilterpull/6/head
parent
f07ad6bb08
commit
98d868e192
|
@ -337,18 +337,21 @@ if (get_option('upload_path') == '.') {
|
||||||
|
|
||||||
function oss_sanitize_file_name($filename)
|
function oss_sanitize_file_name($filename)
|
||||||
{
|
{
|
||||||
$oss_options = get_option('oss_options');
|
$exp = pathinfo($filename["name"],PATHINFO_EXTENSION);//后缀
|
||||||
switch ($oss_options['update_file_name']) {
|
$oss_options = get_option('oss_options')["update_file_name"];
|
||||||
|
switch ($oss_options) {
|
||||||
case 'md5':
|
case 'md5':
|
||||||
return md5($filename) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
|
$filename["name"] = md5($filename) . '.' . $exp;
|
||||||
|
return $filename;
|
||||||
case 'time':
|
case 'time':
|
||||||
return date('YmdHis', current_time('timestamp')) . mt_rand(100, 999) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
|
$filename["name"] = date('YmdHis', current_time('timestamp')) . mt_rand(100, 999) . '.' . $exp;
|
||||||
|
return $filename;
|
||||||
default:
|
default:
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'sanitize_file_name', 'oss_sanitize_file_name', 10, 1 );
|
add_filter( 'wp_handle_upload_prefilter', 'oss_sanitize_file_name', 10, 1 );
|
||||||
|
|
||||||
function oss_function_each(&$array)
|
function oss_function_each(&$array)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue