1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Wordpressで投稿画像のファイル名を英語にリネームする。

Last updated at Posted at 2021-04-10

自分のための忘備録です。


(・ω・)< kubiee君、以前作ったwordpressの画像のファイル名が日本語になってるよ

・・・(やばい・何か問題があるのかな・・?) >(´∇`)

問題点

今後wordpressを引っ越すときにエラーが出るみたいです。
こちらのサイトを参考に過去の投稿画像をリネームしました。

今後の投稿画像も自動で英語にリネームする

functions.phpに以下を追加

functions.php
function rename_file_md5($fileName) {
$i = strrpos($fileName, '.');
if ($i) $Exts = '.'.substr($fileName, $i + 1);
else $Exts = '';
$fileName = md5(time().$fileName).$Exts;
return strtolower($fileName);
}
add_filter('sanitize_file_name', 'rename_file_md5', 10);
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?