<![CDATA[ German umlauts and blanks in image names and paths - My Forums]]> https://forums.modx.com/thread/?thread=80676 <![CDATA[German umlauts and blanks in image names and paths]]> https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444496
probably a common issue but I didn't find a solution when searching the forum...

Whenever users enter directory names including blanks or german umlauts I run into problems:
Image upload does not work correctly (found no error message) if umlauts are included.
phpThumbOf does not like blanks in paths or image names.

Is there a way to change image names / directory names automatically when created? (Blanks to _ and umlauts รค-->ae or similar)

I know you should never use those chars in identifiers... but it will be difficult to teach the users not to use them.


Thanks in advance

Thomas]]>
hochmohr Nov 25, 2012, 12:56 PM https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444496
<![CDATA[Re: German umlauts and blanks in image names and paths]]> https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444653
There was a strange behavior when I uploaded an image from within TinyMCE, which should use the standard file upload manager: The file did not show up in the desired folder but in its parent folder. The same image renamed before upload (without umlauts) worked just fine.

Thomas]]>
hochmohr Nov 26, 2012, 12:57 PM https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444653
<![CDATA[Re: German umlauts and blanks in image names and paths]]> https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444650
was fighting also with german/french umlauts and rewrote/modified the github plugin, code is in this thread:

http://forums.modx.com/thread/73940/revolution-removing-unwanted-forreign-characters-on-file-upload-that-breaks-stuff-like-phpthumb

but what do you mean by "is moved to another path before..."? How are your file uploaded? Not by the modx file manager?]]>
exside Nov 26, 2012, 12:35 PM https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444650
<![CDATA[Re: German umlauts and blanks in image names and paths (Best Answer)]]> https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444642
I tried the github package... nice idea but it did not work on my system (the image with umlauts was written to a wrong directory before the package was able to rename it).
So I tried the first guess shown in the discussion... and it worked!
The only thing I changed for my project is that it will translate the umlauts, so I use the following code (which is not complete yet but a start):

modfilemediasource.class.php in core/model/modx/sources around line 650

            if ($size > $maxFileSize) {
                $this->addError('path',$this->xpdo->lexicon('file_err_too_large',array(
                    'size' => $size,
                    'allowed' => $maxFileSize,
                )));
                continue;
            }

			/////// added / changed lines
            $pat = array('/Ä/','/Ö/','/Ü/','/ä/','/ö/','/ü/','/ß/', '/(á|â|à)/', '/(é|è|ê)/', '/(í|ì|î)/', '/\s+/');
            $rep = array('Ae','Oe','Ue','ae','oe','ue','ss', 'a', 'e', 'i', '_');
            $newPath = preg_replace($pat, $rep, utf8_decode($file['name']));			
            $newPath = $this->fileHandler->sanitizePath($newPath);
//            $newPath = $this->fileHandler->sanitizePath($file['name']);
            ///////

            $newPath = $directory->getPath().$newPath;


The utf8_decode() may result in more problems... anyway I'll try it.

Thomas]]>
hochmohr Nov 26, 2012, 11:37 AM https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444642
<![CDATA[Re: German umlauts and blanks in image names and paths]]> https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444589 exside Nov 26, 2012, 07:28 AM https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444589 <![CDATA[Re: German umlauts and blanks in image names and paths]]> https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444579
take a look at this discussion
Revolution: Removing unwanted forreign characters on file upload that breaks stuff like phpthumb

And here you find a plugin, maybe it helps?
https://github.com/benjamin-vauchel/SanitizeFilename

Manfred]]>
manfred62 Nov 26, 2012, 06:47 AM https://forums.modx.com/thread/80676/german-umlauts-and-blanks-in-image-names-and-paths#dis-post-444579