Notifications
Clear all

WPDiscuz - help with images

8 Posts
4 Users
0 Reactions
3,517 Views
(@WxGuy)
New Member
Joined: 10 years ago
Posts: 2
Topic starter  

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


   
Quote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4209
 

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() )
	 ));

   
ReplyQuote
(@WxGuy)
New Member
Joined: 10 years ago
Posts: 2
Topic starter  

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


   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4209
 

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() )
	 ));

   
ReplyQuote
(@wbrenner)
Active Member
Joined: 9 years ago
Posts: 5
 

Hi. I can't find those files. Could you confirm or detail the correct path? Thank you.


   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4209
 

This is an old post, the current correct path is wpdiscuz/utils/class.WpdiscuzHelper.php


   
ReplyQuote
(@csmwp)
Member Customer
Joined: 7 years ago
Posts: 17
 

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;
}

 


   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4209
 

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;
}

   
ReplyQuote
Share:
Scroll to top