English 中文(简体)
WordPress 3.0media uploader改变我的形象档案。
原标题:WordPress 3.0 media uploader alters my image filename

I vepo into a problem with WordPress 3.0

我以强调性(一些文件.jpg)预示我的形象档案,允许我为某些用途而贴上旗帜,而图象没有强调。

然而,我刚刚发现,在WP3.0中,媒体上载了这些从档案名称中强调的内容。 我首先认为,这只是重新命名图像的标语,但我已核实该词在FTP中,实际上重新命名档案本身。

是否有一种情况,我可以通过文字来阻止编辑这一档案?

最佳回答

职能sanitize_file_name( in wp-includes/formatting.php,行文681:

$filename = trim($filename,  .-_ );

从功能文件上看:“遗产期、干 the和强调从档案开始和结束。

在<代码>trim(>后运行的过滤器名称为sanitize_file_name。 该法典将解决你的问题(未测试):

function preserve_leading_underscore( $filename, $filename_raw ) {
    if( "_" == substr($filename_raw, 0, 1) ) {
        $filename = "_" . $filename;
    }

    return $filename;
}
add_filter( sanitize_file_name ,  preserve_leading_underscore , 10, 2);
问题回答

这里一行:

add_filter( sanitize_file_name ,create_function( $f,$fr , return preg_match("`^_`",$fr) ? "_".$f : $f; ),10,2);

i 至少确认,WordPress 3.5.1正在脱节,增加这一过滤器可保持主线。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签