WordPress Chinese image upload automatic rename

Source: Internet
Author: User

WordPress Chinese image upload automatic rename

Because of the few people in the country to upload pictures before the name of the image renamed to English, so automatic renaming is particularly important for WP, especially Linux does not support Chinese names.

WordPress Upload the multimedia code are stored in \wp-admin\includes\ inside the file.php, open this file,FILENAME=WPUNIQUEFilename( uploads[' path '],FILE[′NA ′], Unique_filename_callback);//Move the file to the Uploads dir, before this sentence $filename assigned valueAdd the following code:

$time =date ("Ymdhis"); $type _change = Array (' image ' = = '); $file _type = STRTR ($file [' type '], $type _change);
$file [' name '] = $time. "". Mt_rand (1,100). "". $file _type;

The following code follows:

    $time =Date ("Ymdhis"); $type _change = array (' image ' = '. ');  $file _type = strtr ($ file[' type '], $type _change); 
$file [' name '] = $time. " mt_rand (1,100). $file _type $filename = Wp_unique_filename ( $file [' name '], $unique _filename_callback// Move the file to the uploads dir span>

Save, after uploading the multimedia file is automatically renamed to 2014012315450088 format, year month date time and random number.

WordPress Chinese image upload automatic rename

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.