SilverStripe 3.1+ change FileNameFilter default replacements

老子叫甜甜 提交于 2019-12-12 04:26:19

问题


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:


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();


来源:https://stackoverflow.com/questions/36944404/silverstripe-3-1-change-filenamefilter-default-replacements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!