簡體   English   中英

由於特殊字符混亂,圖像沒有顯示在wordpress上

[英]Images not showing on wordpress because of special characters mess

我的網站感染了惡意軟件。 在我清理我的網站后,我注意到由於特殊字符問題,一些wordpress圖像沒有顯示。 例如,這是FTP上顯示的圖像名稱

sandí-a-asd-123.jpg

但是,如果我通過此路徑訪問URL,它仍然無法訪問

mysite/imagepath/sandÃ-a-asd-123.jpg

它只能通過這條路徑訪問

mysite/imagepath/sandÃ%C2%ADa-asd-123.jpg

那我該怎么辦? 我應該更改wordpress DB中的所有圖像名稱還是應該通過FTP更改名稱?

謝謝

這個wordpress功能適用於我:從pic名稱中刪除所有特殊字符。 希望它有所幫助:D

functions.php中添加代碼

function sanitize_filename_on_upload($filename) {
$ext = end(explode('.',$filename));
// Replace all weird characters
$sanitized = preg_replace('/[^a-zA-Z0-9-_.]/','', substr($filename, 0, -(strlen($ext)+1)));
// Replace dots inside filename
$sanitized = str_replace('.','-', $sanitized);
return strtolower($sanitized.'.'.$ext);
}

add_filter('sanitize_file_name', 'sanitize_filename_on_upload', 10);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM