AI Assistant
Notifications
Clear all

WPDiscuz - help with images

8 Posts
4 Users
0 Reactions
4,501 Views
(@WxGuy)
New Member
Joined: 11 years ago
Posts: 2
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
  [#70]

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: 11 years ago
Posts: 4248
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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: 11 years ago
Posts: 2
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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: 11 years ago
Posts: 4248
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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: 10 years ago
Posts: 5
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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



   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 11 years ago
Posts: 4248
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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



   
ReplyQuote
(@csmwp)
Member Customer
Joined: 9 years ago
Posts: 17
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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: 11 years ago
Posts: 4248
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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