Allow image plugin in forums
-
Hello,
I have WPMU 2.8.4.a en Buddypress 1.1.2
I try to use the Allow Images plugin (no admin page) (http://bbpress.org/plugins/topic/allow-images/). I made a folder my-plugins (under wp-content/plugins/buddypress/bp-forums/bbpress) and placed the file allow-images.php in this folder, with no result. When I place this file in the mu-plugins folder, no result too Is there a way to activate this plugin? Because Images are realy needed in my forums.
Thanks a lot and thanks for the new Buddypress 1.1.2!
-
BBPress plugins won’t work with the method of integration that BuddyPress uses. You will have to port the plugin to work with WPMU and BudyPress or find someone to do it for you.
Thanks for the tip DJPaul!
With the Skeleton Component Plugin I could allready write a simple plugin. But it seems now I have to look how to rewrite this BBPress plugin… I’ll try
This is what I use in my forums:
function gs_bp_forums_add_allowed_tags( $allowedtags ) {
if ( bp_is_group_forum_topic() ) {
$allowedtags['img'] = array( 'src' => array() );
$allowedtags['del'] = array();
$allowedtags['p'] = array();
$allowedtags['br'] = array();
$allowedtags['cite'] = array();
$allowedtags['blockquote'] = array();
$allowedtags['h3'] = array();
$allowedtags['strong'] = array();
$allowedtags['em'] = array();
}
return $allowedtags;
}
add_action( 'plugins_loaded', 'gs_configure_forum_filters' );
function gs_configure_forum_filters() {
remove_filter( 'bp_get_the_topic_post_content', 'attribute_escape' );
remove_filter( 'bp_get_the_topic_post_content', 'convert_smilies' );
remove_filter( 'bp_get_the_topic_post_content', 'convert_chars' );
add_filter( 'edit_allowedtags', 'gs_bp_forums_add_allowed_tags' );
}Thanks a lot for your code Detective!
Do I have to place this code in a specific file (allow-images.php ?) and where do I have to place this file? Or do I have to change the code in bp-forums-filters.php?
Thanks for your help!!
You can add it to your theme’s functions.php.
tcesco, I recently ported over a version of the more general bbPress attachments plugin by _ck_: https://wordpress.org/extend/plugins/forum-attachments-for-buddypress/. The downside is that I haven’t yet gotten inline images to work, which means that people can upload and download images but they don’t appear as images in the posts (just downloadable file links). Thus it might not work for your purpose, but it’s worth a look.
@Detective: After inserting your code in /wp-content/themes/bp-sn-parent/functions.php I get a white page Sorry for my ignorance but is this the right place? I’m just using the standard Buddypress theme
@Boone Gorges: Thanks for your comment, that’s probably the next step, but first I need to see the images in the forum-posts I’ll have a look at your plugin
InactiveThe best way is to create a file in the plugin directory (/wp-content/plugins), call it as you want (mine is custom.php) and put the code in it.
Here is mine (with a bonus code to modify the admin bar, removing the blog menu and the visit menu):
<?php
function my_alter_bp_adminbar(){
remove_action(‘bp_adminbar_menus’, ‘bp_adminbar_blogs_menu’, 6);
remove_action(‘bp_adminbar_menus’, ‘bp_adminbar_random_menu’, 100);
}
add_action(‘wp_footer’,’my_alter_bp_adminbar’,1);
function gs_bp_forums_add_allowed_tags( $allowedtags ) {
if ( bp_is_group_forum_topic() ) {
$allowedtags[‘img’] = array( ‘src’ => array() );
$allowedtags[‘del’] = array();
$allowedtags[‘p’] = array();
$allowedtags[‘br’] = array();
$allowedtags[‘cite’] = array();
$allowedtags[‘blockquote’] = array();
$allowedtags[‘h3’] = array();
$allowedtags[‘strong’] = array();
$allowedtags[’em’] = array();
}
return $allowedtags;
}
add_action( ‘plugins_loaded’, ‘gs_configure_forum_filters’ );
function gs_configure_forum_filters() {
remove_filter( ‘bp_get_the_topic_post_content’, ‘attribute_escape’ );
remove_filter( ‘bp_get_the_topic_post_content’, ‘convert_smilies’ );
remove_filter( ‘bp_get_the_topic_post_content’, ‘convert_chars’ );
add_filter( ‘edit_allowedtags’, ‘gs_bp_forums_add_allowed_tags’ );
}
?>
@casualgamesfrance
Thanks for your help! Your code works for all the tags given, but not for the images The correct code for inserting a picture is put in the database (without escape character for the quote). But when I look into the fora I can’t see a picture, because In the code of that page, there’s put an escape character before the quote’s.
I removed the add_filter( ‘bp_get_the_topic_post_content’, ‘wp_filter_kses’, 1 ); in /wp-content/plugins/buddypress/forums/bp-forums-filters.php and this solved the problem!!
The next step is to remove this filter in your custom.php file so I can leave buddypress as it is.
Thanks a lot!!
Not the right solution I think because now I can insert whatever html tags
Any suggestions?
has anyone transformed this to buddypress xprofiles?
so that for instance specific tags/html is allowed on profile pages?
this would be really handy.
I’ve managed to adapt the above to enable the use of a href tags, and whilst it works fine in forums, it shows the link in all its verbose glory on the activity streams. Any thoughts on how I can get it to allow the tags in the activity stream?
@hatiro, Can you create it as a plugin for all?
Only really changed the IMG output above to mimic the [a] tag and put the plugin description at the top, dropped it into plugins and activated it.
Problem I’ve got is how to strip out the html in the activity stream, or to turn it into a clickable link with the activity stream…
None of this helps the forum topic here though….sorry…
<?php
/*
Plugin Name: TAG-override
Plugin URI:
Description: Forum tag override function
Version: 0.1
Author:
Author URI:
*.
function gs_bp_forums_add_allowed_tags( $allowedtags ) {
if ( bp_is_group_forum_topic() ) {
$allowedtags[‘a’] = array( ‘href’ => array() );
$allowedtags[‘del’] = array();
$allowedtags[‘p’] = array();
$allowedtags[‘br’] = array();
$allowedtags[‘cite’] = array();
$allowedtags[‘blockquote’] = array();
$allowedtags[‘h3’] = array();
$allowedtags[‘strong’] = array();
$allowedtags[’em’] = array();
}
return $allowedtags;
}
add_action( ‘plugins_loaded’, ‘gs_configure_forum_filters’ );
function gs_configure_forum_filters() {
remove_filter( ‘bp_get_the_topic_post_content’, ‘attribute_escape’ );
remove_filter( ‘bp_get_the_topic_post_content’, ‘convert_smilies’ );
remove_filter( ‘bp_get_the_topic_post_content’, ‘convert_chars’ );
add_filter( ‘edit_allowedtags’, ‘gs_bp_forums_add_allowed_tags’ );
}
?>
OK to finish this off so that the topic can get back onto the image resolution.
in bp-activity-templatetags.php ~line 258 there is the function bp_activity_content. in the return apply_filters part at the bottom of the function replacing $content with html_entity_decode( srt_replace( ‘%s’, ”, $content ), ENT_compat, ‘UTF-8’) seemed to do the trick. I copied it from the filter for the rss feed futher down on line ~462…
Apologies to those trying to get images to work, but this thread helped me sort out my problem.
- The topic ‘Allow image plugin in forums’ is closed to new replies.