Sanitizes a filename, replacing whitespace with dashes. Removes special characters that are illegal in filenames on certain operating systems and special characters requiring special escaping to manipulate at the command line. Replaces spaces and consecutive dashes with a single dash. Trims period, dash and underscore from beginning and end of filename. It is not guaranteed that this function will return a filename that is allowed to be uploaded.
Assainit un nom de fichier en remplaçant les espaces blancs par des tirets. Supprime les caractères spéciaux illégaux dans les noms de fichiers sur certains systèmes d'exploitation et les caractères spéciaux nécessitant un échappement spécial pour être manipulés sur la ligne de commande. Remplace les espaces et les tirets consécutifs par un seul tiret. Supprime le point, le tiret et le trait de soulignement au début et à la fin du nom de fichier. Il n'est pas garanti que cette fonction renvoie un nom de fichier autorisé à être téléchargé.
$filename
Sortie :
@param string $filename The filename to be sanitized. @return string The sanitized filename.
add_filter('sanitize_file_name', 'custom_file_sanitize');
function custom_file_sanitize($filename) {
$filename = preg_replace('/[^a-z0-9._-]/i', '', $filename);
return strtolower($filename);
}
Chargement des actualités...