verbally3715
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [Phoenix Media Rename] Feature Request: Sanitize Non-English LettersAlright that works well, I did improve it a little bit if anyone wants it.
add_filter('sanitize_file_name', function ($filename) {
$greek_map = [
// Common digraphs first (strtr uses the longest match anyway)
'ου' => 'ou', 'ού' => 'ou', 'Ου' => 'Ou', 'Ού' => 'Ou', 'ΟΥ' => 'OU', 'ΟΎ' => 'OU',
// Lowercase
'α' => 'a', 'β' => 'v', 'γ' => 'g', 'δ' => 'd', 'ε' => 'e', 'ζ' => 'z',
'η' => 'i', 'θ' => 'th', 'ι' => 'i', 'κ' => 'k', 'λ' => 'l', 'μ' => 'm',
'ν' => 'n', 'ξ' => 'ks', 'ο' => 'o', 'π' => 'p', 'ρ' => 'r', 'σ' => 's',
'ς' => 's', 'τ' => 't', 'υ' => 'u', 'φ' => 'f', 'χ' => 'x', 'ψ' => 'ps',
'ω' => 'o',
// Lowercase accented and diaeresis
'ά' => 'a', 'έ' => 'e', 'ή' => 'i', 'ί' => 'i', 'ό' => 'o', 'ύ' => 'u', 'ώ' => 'o',
'ϊ' => 'i', 'ΐ' => 'i', 'ϋ' => 'u', 'ΰ' => 'u',
// Uppercase
'Α' => 'A', 'Β' => 'V', 'Γ' => 'G', 'Δ' => 'D', 'Ε' => 'E', 'Ζ' => 'Z',
'Η' => 'I', 'Θ' => 'TH', 'Ι' => 'I', 'Κ' => 'K', 'Λ' => 'L', 'Μ' => 'M',
'Ν' => 'N', 'Ξ' => 'KS', 'Ο' => 'O', 'Π' => 'P', 'Ρ' => 'R', 'Σ' => 'S',
'Τ' => 'T', 'Υ' => 'U', 'Φ' => 'F', 'Χ' => 'X', 'Ψ' => 'PS', 'Ω' => 'O',
// Uppercase accented and diaeresis
'Ά' => 'A', 'Έ' => 'E', 'Ή' => 'I', 'Ί' => 'I', 'Ό' => 'O', 'Ύ' => 'U', 'Ώ' => 'O',
'Ϊ' => 'I', 'Ϋ' => 'U',
];
return strtr($filename, $greek_map);
});Now I just have one small problem, is there a way where “Rename & Retittle from Post” can run on media I upload on products automatically? Because now I have to create the products and then manually go to Media and rename.
Viewing 1 replies (of 1 total)