- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一张图片,文件名为 Chu Thái.jpg
。上传到媒体库时,hosting里面的文件名已经重命名为Chu-Thá¡i.jpg
,但是图片的路径和文件名不一样:http://bem.vn/httq/wp-content/uploads/sites/2/2013/10/Chu-Thái.jpg
因此,当将 url 复制到浏览器时,它会说在此服务器上找不到该文件。
在此服务器上找不到请求的 URL/wp-head/wp-content/uploads/sites/2/2013/10/Chu-Thái-150x150.jpg。
我想知道问题是由 Wordpress 还是我的托管引起的?
最佳答案
问题是您不应该上传包含特殊字符的文件。我在 plugin of mine 中使用的是什么是过滤器 sanitize_file_name
.
我最终从 this plugin 中提取并调整了 3 个函数, 以便对上传的文件名进行全面清理,以免出现此类错误:
add_filter( 'sanitize_file_name', 't5_sanitize_filename', 10 );
/**
* Clean up uploaded file names
*
* Sanitization test done with the filename:
* ÄäÆæÀàÁáÂâÃãÅåªₐāĆćÇçÐđÈèÉéÊêËëₑƒğĞÌìÍíÎîÏïīıÑñⁿÒòÓóÔôÕõØøₒÖöŒœßŠšşŞ™ÙùÚúÛûÜüÝýÿŽž¢€‰№$℃°C℉°F⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉±×₊₌⁼⁻₋–—‑․‥…‧.png
* @author toscho
* @url https://github.com/toscho/Germanix-WordPress-Plugin
*/
function t5_sanitize_filename( $filename )
{
$filename = html_entity_decode( $filename, ENT_QUOTES, 'utf-8' );
$filename = t5_translit( $filename );
$filename = t5_lower_ascii( $filename );
$filename = t5_remove_doubles( $filename );
return $filename;
}
/**
* Converts uppercase characters to lowercase and removes the rest.
* https://github.com/toscho/Germanix-WordPress-Plugin
*
* @uses apply_filters( 'germanix_lower_ascii_regex' )
* @param string $str Input string
* @return string
*/
function t5_lower_ascii( $str )
{
$str = strtolower( $str );
$regex = array(
'pattern' => '~([^a-z\d_.-])~'
, 'replacement' => ''
);
// Leave underscores, otherwise the taxonomy tag cloud in the
// backend won’t work anymore.
return preg_replace( $regex['pattern'], $regex['replacement'], $str );
}
/**
* Reduces repeated meta characters (-=+.) to one.
* https://github.com/toscho/Germanix-WordPress-Plugin
*
* @uses apply_filters( 'germanix_remove_doubles_regex' )
* @param string $str Input string
* @return string
*/
function t5_remove_doubles( $str )
{
$regex = apply_filters(
'germanix_remove_doubles_regex'
, array(
'pattern' => '~([=+.-])\\1+~'
, 'replacement' => "\\1"
)
);
return preg_replace( $regex['pattern'], $regex['replacement'], $str );
}
/**
* Replaces non ASCII chars.
* https://github.com/toscho/Germanix-WordPress-Plugin
*
* wp-includes/formatting.php#L531 is unfortunately completely inappropriate.
* Modified version of Heiko Rabe’s code.
*
* @author Heiko Rabe http://code-styling.de
* @link http://www.code-styling.de/?p=574
* @param string $str
* @return string
*/
function t5_translit( $str )
{
$utf8 = array(
'Ä' => 'Ae'
, 'ä' => 'ae'
, 'Æ' => 'Ae'
, 'æ' => 'ae'
, 'À' => 'A'
, 'à' => 'a'
, 'Á' => 'A'
, 'á' => 'a'
, 'Â' => 'A'
, 'â' => 'a'
, 'Ã' => 'A'
, 'ã' => 'a'
, 'Å' => 'A'
, 'å' => 'a'
, 'ª' => 'a'
, 'ₐ' => 'a'
, 'ā' => 'a'
, 'Ć' => 'C'
, 'ć' => 'c'
, 'Ç' => 'C'
, 'ç' => 'c'
, 'Ð' => 'D'
, 'đ' => 'd'
, 'È' => 'E'
, 'è' => 'e'
, 'É' => 'E'
, 'é' => 'e'
, 'Ê' => 'E'
, 'ê' => 'e'
, 'Ë' => 'E'
, 'ë' => 'e'
, 'ₑ' => 'e'
, 'ƒ' => 'f'
, 'ğ' => 'g'
, 'Ğ' => 'G'
, 'Ì' => 'I'
, 'ì' => 'i'
, 'Í' => 'I'
, 'í' => 'i'
, 'Î' => 'I'
, 'î' => 'i'
, 'Ï' => 'Ii'
, 'ï' => 'ii'
, 'ī' => 'i'
, 'ı' => 'i'
, 'I' => 'I' // turkish, correct?
, 'Ñ' => 'N'
, 'ñ' => 'n'
, 'ⁿ' => 'n'
, 'Ò' => 'O'
, 'ò' => 'o'
, 'Ó' => 'O'
, 'ó' => 'o'
, 'Ô' => 'O'
, 'ô' => 'o'
, 'Õ' => 'O'
, 'õ' => 'o'
, 'Ø' => 'O'
, 'ø' => 'o'
, 'ₒ' => 'o'
, 'Ö' => 'Oe'
, 'ö' => 'oe'
, 'Œ' => 'Oe'
, 'œ' => 'oe'
, 'ß' => 'ss'
, 'Š' => 'S'
, 'š' => 's'
, 'ş' => 's'
, 'Ş' => 'S'
, '™' => 'TM'
, 'Ù' => 'U'
, 'ù' => 'u'
, 'Ú' => 'U'
, 'ú' => 'u'
, 'Û' => 'U'
, 'û' => 'u'
, 'Ü' => 'Ue'
, 'ü' => 'ue'
, 'Ý' => 'Y'
, 'ý' => 'y'
, 'ÿ' => 'y'
, 'Ž' => 'Z'
, 'ž' => 'z'
// misc
, '¢' => 'Cent'
, '€' => 'Euro'
, '‰' => 'promille'
, '№' => 'Nr'
, '$' => 'Dollar'
, '℃' => 'Grad Celsius'
, '°C' => 'Grad Celsius'
, '℉' => 'Grad Fahrenheit'
, '°F' => 'Grad Fahrenheit'
// Superscripts
, '⁰' => '0'
, '¹' => '1'
, '²' => '2'
, '³' => '3'
, '⁴' => '4'
, '⁵' => '5'
, '⁶' => '6'
, '⁷' => '7'
, '⁸' => '8'
, '⁹' => '9'
// Subscripts
, '₀' => '0'
, '₁' => '1'
, '₂' => '2'
, '₃' => '3'
, '₄' => '4'
, '₅' => '5'
, '₆' => '6'
, '₇' => '7'
, '₈' => '8'
, '₉' => '9'
// Operators, punctuation
, '±' => 'plusminus'
, '×' => 'x'
, '₊' => 'plus'
, '₌' => '='
, '⁼' => '='
, '⁻' => '-' // sup minus
, '₋' => '-' // sub minus
, '–' => '-' // ndash
, '—' => '-' // mdash
, '‑' => '-' // non breaking hyphen
, '․' => '.' // one dot leader
, '‥' => '..' // two dot leader
, '…' => '...' // ellipsis
, '‧' => '.' // hyphenation point
, ' ' => '-' // nobreak space
, ' ' => '-' // normal space
);
$str = strtr( $str, $utf8 );
return trim( $str, '-' );
}
关于php - 浏览器无法读取包含特殊字符的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19444031/
我的“登录”是在 IE 浏览器中进行的,登录后,如果我单击链接,它们就会在 Chrome 浏览器中打开。如何在同一个测试用例中将我当前的浏览器从 IE 切换到 Chrome。如果我创建一个 chrom
您好,我不明白在 Firefox 的内容属性中使用的特殊字符的不同显示行为。我已经剥离了一切并创造了一支笔: http://codepen.io/rpkoller/pen/Fbgav 在其“基本形式”
我正在研究 Spring Data REST,特别是 HAL 浏览器。我一直在关注 http://docs.spring.io/spring-data/rest/docs/current/refere
我正在使用工具提示,在 ie 上出现定位错误。我放了jquery浏览器代码 我的工具提示 $('.tooltip').tooltip({ position: "bottom center"
我应该如何处理蓝鸟协程中的错误? 我使用co in节点已有一段时间,它具有出色的捕获功能。 co(function*() { return new Promise(function(resol
package webviewbrowser; import java.util.List; import javafx.application.Application; import javafx.
我有一些 JavaScript 在同一域上的两个独立服务器之间共享请求。 .com 是 JavaScript 中域的要求吗? 在这种情况下,两台服务器都位于 .abc.tyy 域上,tyy 通常是 .
package webviewbrowser; import java.util.List; import javafx.application.Application; import javafx.
我正在尝试构建仍支持 NPAPI 的先前版本的 Chromium 浏览器。我已经获得了代码,并且可以使用 stand build 命令在我的 mac 上构建最新版本的 Chromium gclient
我环顾四周,找不到 browscap 的 Python 等效项(我在 PHP 中使用它来检测给定的用户代理字符串是什么浏览器。 我希望我不必自己写......:P 最佳答案 看看这个,它应该做你想要的
是否有任何 chrome 或 firefox 扩展允许 javascript 在客户端 PC 中创建写入文件? 最佳答案 你想做什么? HTML5 有一个 File API .这是最好的解决方案,因为
当我点击链接或刷新或关闭标签页时,我有这段代码会发出警报。 但我需要在关闭 窗口(选项卡)上仅 发出警报。怎么做? 我的网站上有很多外部和内部链接。
我目前正在尝试使用 Browserify + Angular,但我遇到了一个奇怪的问题。我在我的 Controller 的子目录中创建了一个名为 controllers/start-controlle
我正在为客户(项目已被接受,但现在是解释不同功能的问题)写一份详细的估算,以开发一个响应式布局的网站。 这不是我第一次进行此类开发,但这是一个关键客户,必须铺平道路。 布局将从 300px 宽度调整到
我在时事通讯上设计了一些黑底白字。由于时事通讯在打印时看起来不错且可读。我需要使布局和文本与浏览器中的内容相似。 通常情况下,黑色文本和无背景颜色是浏览器/网络邮件客户端的默认打印样式吗? 最佳答案
我有一个使用 GWT/mGWT 构建的移动友好网络应用程序。该应用程序有白色输入文本框和深灰色输入文本。但是,在 Android 浏览器上,文本显示为白色,因此是不可见的。我尝试的所有 CSS 都无法
我创建了一个带有选择输入的页面来更改正在使用的 jQuery UI 主题。当主题更改时,它会存储在 cookie 中。页面加载时,如果 cookie 存在,则恢复主题,否则加载默认主题。 当我使用 F
在我的 CSS 中,我使用了以下代码片段: word-break: break-word; -webkit-hyphens: auto; hyphens: auto; 渲染引擎如何知道在所有不同语言中
我的网络浏览器 Safari 有问题,我在 Chrome、FireFox 中测试了我的网站。 Safari 版本也是正确的,但是,当需要在 1920x1080 或更高分辨率下对其进行测试时,它无法正常
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我是一名优秀的程序员,十分优秀!