당신은 파일 업로드를 처리 및 필터 wp_handle_upload_prefilter
에 중독 될 것이다, 당신의 functions.php
파일에서 함수를 작성해야합니다 :
add_filter('wp_handle_upload_prefilter', 'wp_rename_large_images', 1, 1);
//Check to see if function name is unique
if (!function_exists("wp_rename_large_images")) {
function wp_rename_large_images($file){
//Get image size
$img = getimagesize($file['tmp_name']);
//Image dimensions
$width = $img[0];
$height = $img[1];
//Check to see if image is large enough to change the file name
if ($width > 1200 || $height > 1080) {
//Modify the file name WITH an extension
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
//Build the new file name (remove the old extension - last 3 characters from the file name, i.e. jpg, gif, png, bmp, etc.)
$file['name'] = substr($file['name'], -3) . '-large'. $ext;
}
return $file;
}
}
이 문서
here를 참조하십시오.
: http://cl.ly/image/031M2b1U1m1Y 파일에 문제가있을 수 있습니다 신장? –
이상한 점이 있습니다 ... 다른 MIME 형식이 아닌 이미지를 업로드 하시겠습니까? – bodi0
확장자가 이미 파일 이름에 있으므로 $ filetype [ 'ext']은 필요하지 않습니다. 그것이 문제였습니다. –