post by newdev on Mar 19, 2024
post by newdev on Mar 19, 2024
I comment
$filename = preg_replace(“/([^a-zA-Z0-9-_ ]+?){1}/i”, ‘’, $filename);
in UploadHelper is work.
post by johnny on Mar 19, 2024
Hello @newdev ,
You can add some extra characters into the file name Transliteration.php which is on: vendor/grocery-crud/enterprise/src/GroceryCrud/Core/Upload/Transliteration.php to also include the Thai letters. For example:
<?php
namespace GroceryCrud\Core\Upload;
class Transliteration {
public static function convertFilename($filename) {
$translit_characters = Transliteration::getTranslitCharacters();
return preg_replace(array_keys($translit_characters), array_values($translit_characters), $filename);
}
public static function getTranslitCharacters() {
return [
// Thai characters
'/ก/' => 'k',
'/ข/' => 'kh',
'/ฃ/' => 'kh',
'/ค/' => 'k',
'/ฅ/' => 'kh',
'/ฆ/' => 'kh',
'/ง/' => 'ng',
'/จ/' => 'j',
'/ฉ/' => 'ch',
'/ช/' => 'ch',
'/ซ/' => 's',
'/ฌ/' => 'ch',
'/ญ/' => 'y',
'/ฎ/' => 'd',
'/ฏ/' => 't',
'/ฐ/' => 'th',
'/ฑ/' => 'th',
'/ฒ/' => 'th',
'/ณ/' => 'n',
'/ด/' => 'd',
'/ต/' => 't',
'/ถ/' => 'th',
'/ท/' => 'th',
'/ธ/' => 'th',
'/น/' => 'n',
'/บ/' => 'b',
'/ป/' => 'p',
'/ผ/' => 'ph',
'/ฝ/' => 'f',
'/พ/' => 'ph',
'/ฟ/' => 'f',
'/ภ/' => 'ph',
'/ม/' => 'm',
'/ย/' => 'y',
'/ร/' => 'r',
'/ล/' => 'l',
'/ว/' => 'w',
'/ศ/' => 's',
'/ษ/' => 's',
'/ส/' => 's',
'/ห/' => 'h',
'/ฬ/' => 'l',
'/อ/' => 'o',
'/ฮ/' => 'h',
// Other characters within the file
];
}
}
We have added a Transliteration because it is better to have english characters on files we use on the web. But of course it is up to you, if you would like to exclude the transformation you can remove the regular expression.
Regards
Johnny
New & Unread Topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Setting quick search values via JavaScript not working properly for booleans |
|
0 | 563 | Nov 2025 |
| callbackColumn() has not effect in v3.2.6 Enterprise |
|
2 | 696 | Dec 2025 |
| displayAs() doesn’t support new line in headings |
|
4 | 871 | Jan 5 |
| Inline edit has problems if the column width is set |
|
2 | 842 | Feb 28 |
| “Ooooops, something went wrong! If you can see this message, this is probably a misconfiguration in Grocery CRUD Enterprise!” |
|
6 | 264 | 8d |
