bbPress : 画像を貼り付けられる様にする
bbPressには標準で画像を添付する事ができません。
つまり、imgタグなどが使えないって事です。
それを使えるようにする方法が紹介されていました。
方法は、
bb-includes/formatting-functions.php の
58行目あたり、function encode_bad( $text ) 以下に
$text = preg_replace('|&amp;lt;(/?img.*?)&amp;gt;|', '<$1>', $text);
を追加します。
function encode_bad( $text ) { $text = wp_specialchars($text); $text = preg_replace('|<(/?strong)>|', '<$1>', $text); $text = preg_replace('|<(/?em)>|', '<$1>', $text); $text = preg_replace('|<(/?a.*?)>|', '<$1>', $text); $text = preg_replace('|<(/?ol)>|', '<$1>', $text); $text = preg_replace('|<(/?p)>|', '<$1>', $text); $text = preg_replace('|<br />|', '<br />', $text); $text = preg_replace('|<(/?ul)>|', '<$1>', $text); $text = preg_replace('|<(/?li)>|', '<$1>', $text); $text = preg_replace('|<(/?blockquote.*?)>|', '<$1>', $text); $text = preg_replace('|<(/?code)>|', '<$1>', $text); $text = preg_replace("|`(.*?)`|se", "'<code>' . encodeit('$1') . '</code>'", $text); $text = preg_replace('|&amp;lt;(/?img.*?)&amp;gt;|', '<$1>', $text); return $text; }
次に、87行目あたり function bb_allowed_tags() { 以下に
'img' => array( 'src' => array(), 'alt' => array(), 'title' => array()),
を追加します。
function bb_allowed_tags() { $tags = array( 'a' => array( 'href' => array(), 'title' => array(), 'rel' => array()), 'blockquote' => array('cite' => array()), 'br' => array(), 'code' => array(), 'em' => array(), 'strong' => array(), 'ul' => array(), 'ol' => array(), 'li' => array() 'img' => array( 'src' => array(), 'alt' => array(), 'title' => array()), ); return apply_filters( 'bb_allowed_tags', $tags ); }
これで imgタグ が使えるようになるはずです。
ちなみに、0.73で試しました。
動作デモは、



Recent Comments