我想在我的主題的functions.php文件中使用add_filter()來覆蓋一個核心的Wordpress函數(在media.php中找到)。這應該符合我遇到的博客,但出於某種原因,我看不出任何改變。重寫一個核心的Wordpress函數 - 應該可以,但它不會
#override what WP is trying to do to scaling images by default
function my_image_hwstring($width, $height) {
$out = '';
#if ($width)
# $out .= 'width="'.intval($width).'" ';
#if ($height)
# $out .= 'height="'.intval($height).'" ';
return $out;
}
add_filter('image_hwstring', 'my_image_hwstring', 1, 2);
我寧願不手動編輯media.php,因爲之後的任何Wordpress升級都會覆蓋我們所做的更改。我這樣做的方式是正確的(我認爲),但不能按預期工作。
完全掛在這,並感謝任何迴應。這是一個奇怪的!
這一個。 media.php中的image_hwstring()作爲核心文件的一部分。根據我在網上找到的參考資料,我應該能夠使用上面我嘗試使用的示例覆蓋任何核心功能。 – 2010-04-18 22:02:47
應該可以。檢查codex.wordpress.org/Plugin_Resources – markratledge 2010-04-19 16:15:38