Created
March 16, 2017 18:58
-
-
Save CarlosLongarela/a51f6e6f12c14b64eece6f5af084dad1 to your computer and use it in GitHub Desktop.
Función para renombrar los archivos subidos a la mediateca de WordPress
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
function dng_nombre_archivo( $filename, $filename_raw ) { | |
$info = pathinfo( $filename ); | |
$nombre_arch = $info['filename']; | |
if ( ! empty( $info['extension'] ) ) { | |
$ext = $info['extension']; | |
} else { | |
$ext = ''; | |
} | |
$nombre_archivo = str_replace( '_', '-', $nombre_arch ); | |
$nombre_archivo = sanitize_title( $nombre_archivo ); | |
$nombre_archivo = $nombre_archivo . '.' . $ext; | |
return $nombre_archivo; | |
} | |
add_filter( 'sanitize_file_name', 'dng_nombre_archivo', 10, 2 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment