• Resolved abitofmind

    (@abitofmind)


    Meanwhile found the relevant doc:

    https://developer.www.ads-software.com/reference/functions/sanitize_file_name/

    Whether/how can Media File Renamer (MFR) rules or user filters interact/overrule what’s happening in wp-includes/formatting.php ?

    See me 3 questions as inline comments:

    function sanitize_file_name( $filename ) {
    
    	$filename_raw = $filename;
    
    	// 1) Do MFR rules or user filters change ("overload" is the term AFAIR) the remove_accents() function?
    	$filename     = remove_accents( $filename );
    
    	// ...
    
    	// 2) Do MFR rules or user filters change the $special_chars / sanitize_file_name_chars constant ?
    
    	$special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '?', '?', '”', '“', chr( 0 ) );
    
    
    	$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
    
    	$filename = str_replace( $special_chars, '', $filename );
    
    	$filename = str_replace( array( '%20', '+' ), '-', $filename );
    	$filename = preg_replace( '/\.{2,}/', '.', $filename );
    
    	// 3) Possible to override this rule which reduces consecutive whitespace and hyphens to a single hyphen?
    	$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
    	$filename = trim( $filename, '.-_' );
Viewing 1 replies (of 1 total)
  • Plugin Support Val Meow

    (@valwa)

    Hello @abitofmind ,

    Media File Renamer’s user filters do not directly interact or overrule what’s happening in wp-includes/formatting.php. The wp-includes/formatting.php file contains core WordPress functions for formatting and sanitizing text, such as removing illegal characters from filenames. These functions are used by WordPress and plugins, to ensure that text is safe and valid for use in filenames, URLs, and other contexts.

    That being said, you can explore your range of manual interraction by reading the customization documentation.

    Hope this helps ??

Viewing 1 replies (of 1 total)
  • The topic ‘Interplay: Media File Renamer ?? WP sanitize_file_name() in formatting.php’ is closed to new replies.