Created
January 31, 2020 09:32
-
-
Save danielstrelec/d0e592af67d815506feee6ddb2d9e825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// odstranění češtiny a speciálních znaků z vkládaných souborů | |
function wt_sanitize_files ( $filename ) { | |
return remove_accents( $filename ); | |
} | |
add_filter( 'sanitize_file_name', 'wt_sanitize_files', 10 ); | |
?> |
Já bych to vytunil takto :)
add_filter('sanitize_file_name', 'sanitize_title');
Tohle je super krátké, ale nahradí to i tečky (.jpg = -jpg) a udělá lowercase.
Každopádně super tip - díky,
Počítal jsem s tím, že se ta funkce dá upravit podle libosti - třeba přidat prefix, nebo nějaká další magie :).
Máš pravdu, nahrazuji za následující:
add_filter( 'sanitize_file_name', 'wt_sanitize_files' );
function wt_sanitize_files( $filename ) {
$dotp = strrpos( $filename, '.' );
return sanitize_title( substr( $filename, 0, $dotp ) ) . '.' . sanitize_title( substr( $filename, $dotp + 1 ) );
}
Máš pravdu, nahrazuji za následující:
add_filter( 'sanitize_file_name', 'wt_sanitize_files' ); function wt_sanitize_files( $filename ) { $dotp = strrpos( $filename, '.' ); return sanitize_title( substr( $filename, 0, $dotp ) ) . '.' . sanitize_title( substr( $filename, $dotp + 1 ) ); }
Díky za doplnění!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Já bych to vytunil takto :)