私は同じ問題があり、答えを探していました。私は今この方法でそれを解決しました。 index.phpにUploadHandler()クラスを拡張して、必要なメソッドを編集するだけです。必要なメソッドは、get_scaled_image_file_paths()と呼ばれます。 if-conditionの中でファイルのパスと名前を変更することができます。ここにあなたのindex.phpのように見えることができる方法の例は:あなたが$オプションアレイを使用したい場合は
require('UploadHandler.php');
class CustomUploadHandler extends UploadHandler {
protected function get_scaled_image_file_paths($file_name, $version) {
$file_path = $this->get_upload_path($file_name);
if (!empty($version)) {
$version_dir = $this->get_upload_path(null, $version);
if (!is_dir($version_dir)) {
mkdir($version_dir, $this->options['mkdir_mode'], true);
}
switch (strtolower(pathinfo($file_path, PATHINFO_EXTENSION))) {
case 'jpeg':
case 'jpg':
$file_type = 'jpg';
break;
case 'png':
$file_type = 'png';
break;
case 'gif':
$file_type = 'gif';
break;
}
$file_name = 'custom_prefix_'.$version.'.'.$file_type;
$new_file_path = $version_dir.'/'.$file_name;
} else {
$new_file_path = $file_path;
}
return array($file_path, $new_file_path);
}
}
$options = array(
'image_versions' => array(
'' => array(
// Automatically rotate images based on EXIF meta data:
'auto_orient' => true
),
'100' => array(
'upload_dir' => $_SERVER['DOCUMENT_ROOT'].'/uploads/thumbs/',
'upload_url' => 'http://my.url/uploads/thumbs/',
'max_width' => 100,
'max_height' => 100
),
'500' => array(
'upload_dir' => $_SERVER['DOCUMENT_ROOT'].'/uploads/thumbs/',
'upload_url' => 'http://my.url/uploads/thumbs/',
'max_width' => 500,
'max_height' => 500
),
)
);
$upload_handler = new CustomUploadHandler($options);
は方法でビルドがある
$options = $this->options;
私はこれが役に立てば幸い:)
ああ、親切な人、ありがとう! –