SilverStripe 3.1+ change FileNameFilter default re

2019-09-05 02:05发布

Currently uploading a file with an '_' (underscore) in it is automatically replace with '-' (hyphen). I need them to stay as _ . The same as this issue: https://github.com/silverstripe/silverstripe-cms/issues/719

I've discovered this happens via FileNameFilter http://api.silverstripe.org/master/class-FileNameFilter.html#_setReplacements

I've tried to follow the instructions to stop this by adding this to the YAML config:

FileNameFilter:
  default_use_transliterator: false
  default_replacements:

This has no effect do I need to state the new defaults?

And also changing this line:

'/_/' => '-', // underscores to dashes

to this

'/_/' => '_', // underscores to dashes

But this just removes them and closes the gap..

Could someone advise on the correct way to achieve this?

1条回答
Root(大扎)
2楼-- · 2019-09-05 02:57

I realised you can do this in your _config.php file too! And this has worked. I'll leave this question up incase this is useful for anyone like me.

_config.php

FileNameFilter::$default_use_transliterator = false;
FileNameFilter::$default_replacements = array();
查看更多
登录 后发表回答