SilverStripe 3.1+更改FileNameFilter默认替换 [英] SilverStripe 3.1+ change FileNameFilter default replacements

查看:155
本文介绍了SilverStripe 3.1+更改FileNameFilter默认替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前上传一个带有'_'(下划线)的文件会自动替换为' - '(连字符)。我需要他们留下来。
与此问题相同: https://github.com/silverstripe/silverstripe -cms / issues / 719



我发现这是通过FileNameFilter发生的 http://api.silverstripe.org/master/class-FileNameFilter.html#_setReplacements



  FileNameFilter:$ b $我试过按照说明来停止这个操作b default_use_transliterator:false 
default_replacements:

这不起作用吗?

也改变这一行:

$ $ $ $ $ $ $ $ $ $' /'=> ' - ',//下划线

至此

 '/ _ /'=> '_',//强调破折号

但是这只是消除了它们并缩小了差距。 / p>

有人建议用正确的方法来达到这个目的吗?

解决方案

我意识到你也可以在你的_config.php文件中做到这一点!而这一直奏效。我会离开这个问题,这对像我这样的人是有用的。

$ _config.php

  FileNameFilter :: $ default_use_transliterator = false; 
FileNameFilter :: $ default_replacements = array();


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?

解决方案

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

这篇关于SilverStripe 3.1+更改FileNameFilter默认替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆