First - awesome plugin work. Very clean and functional!
My question is I would like users to be able to post images in the comments. (from links not from the wordpress database)
Is there a way to enable image links to display actual images?
Thanks
Hi WxGuy,
There is not any option to turn on image support in wpDiscuz. You should make some hard-code to get it.
Please open /wpdiscuz/wc.php file and find this code:
$comment = wp_kses($comment, array( 'br' => array(), 'a' => array('href' => array(), 'title' => array()), 'i' => array(), 'b' => array(), 'u' => array(), 'strong' => array(), 'p' => array() ));
And change it to this:
$comment = wp_kses($comment, array( 'br' => array(), 'a' => array('href' => array(), 'title' => array()), 'i' => array(), 'b' => array(), 'u' => array(), 'strong' => array(), 'p' => array(), 'img' => array( 'src'=>array(), 'width'=>array(), 'height'=>array(), 'alt'=>array() ) ));
Thanks for your help!
I replaced the code as you requested, and I still just get a link. Do I need to have my plugin settings a certain way too?
Thanks again
Hi WxGuy,
Ok, you should also do the same change in /wpdiscuz/comment-form/tpl-comment.php file.
Please open this file and find this code:
$comment_content = wp_kses($comment->comment_content, array( 'br' => array(), 'a' => array('href' => array(), 'title' => array()), 'i' => array(), 'b' => array(), 'u' => array(), 'strong' => array(), 'p' => array() ));
and change it to this:
$comment_content = wp_kses($comment->comment_content, array( 'br' => array(), 'a' => array('href' => array(), 'title' => array()), 'i' => array(), 'b' => array(), 'u' => array(), 'strong' => array(), 'p' => array(), 'img' => array( 'src'=>array(), 'width'=>array(), 'height'=>array(), 'alt'=>array() ) ));
Hi. I can't find those files. Could you confirm or detail the correct path? Thank you.
This is an old post, the current correct path is wpdiscuz/utils/class.WpdiscuzHelper.php
It looks like we should be able, right now, to add support for images by adding a filter. I have tried this but it is not working. Can you point me in the right direction?
add_action( 'plugins_loaded', 'csm_is_wpdiscuz_active' );
function csm_is_wpdiscuz_active() {
if ( class_exists( 'WpdiscuzCore' ) ) :
add_filter( 'wpdiscuz_allowedtags', 'csm_add_wpdiscuz_img_support');
endif;
}
/**
* @param $allowedtags
*
* @return mixed
*/function csm_add_wpdiscuz_img_support( $allowedtags ) {
$allowedtags['img'] = array( 'src'=>array(), 'width'=>array(), 'height'=>array(), 'alt'=>array() );
return $allowedtags;
}
Try to hook it directly like this:
add_filter( 'wpdiscuz_allowedtags', 'csm_add_wpdiscuz_img_support');
function csm_add_wpdiscuz_img_support( $allowedtags ) {
$allowedtags['img'] = array( 'src'=>array(), 'width'=>array(), 'height'=>array(), 'alt'=>array() );
return $allowedtags;
}