• Hello.

    I think it would be better if the final preg_replace() on line 91 of wp-sanitize-file-name-plus.php replaced remaining non-ascii characters with “-” or “x” not “”.

    A file named яштф?кбй?мыпдф.jpg for example will become just .jpg on uploading, which can cause weirdness.

    This plugin is awesome. Love that it doesn’t have settings and doesn’t need them.
    This should be part of core. I don’t know how the Drupal module “transliterate” is so popular but something like this is not popular on WordPress.

    https://www.ads-software.com/plugins/wp-sanitize-file-name-plus/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter squarecandy

    (@squarecandy)

    added these to the $invalid array:

    ' '=>'-',
    '%20'=>'-'

    And changed line 91 to

    $sanitized_filename = preg_replace('/[^a-zA-Z0-9-_\.]/', 'x', strtolower($sanitized_filename));

    This seems to produce much more useful results, even if filenames with a bunch of x’s look odd.

    Plugin Author Yslo

    (@yslo)

    Thank you, good idea, I’ll add your improvement in the next release.

    Plugin Author Yslo

    (@yslo)

    Hello,

    Spaces where removed, no needs to add : ‘ ‘=>’-‘,

    ‘%20’=>’-‘ added in 1.0.3

    Line 91 changed in 1.0.3

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘do final replace with dash, not nothing; avoid empty filename’ is closed to new replies.