Thanks for this plugin, it works great.
Is there any way, however, to restrict the image size? If someone posts a large image it completely messed up my layout :(
Version: 0.9
Last Updated: 2009-10-24
Requires bbPress Version: 0.8.4 or higher
Compatible up to: 1.0.2





Thanks for this plugin, it works great.
Is there any way, however, to restrict the image size? If someone posts a large image it completely messed up my layout :(
Image size restriction has to be done either via javascript or via your own upload (something I am working on).
For now you can make sure large images don't mess up your layout by applying overflow:hidden; to the CSS - my educated guess would be to the .threadpost element, or #thread (or #thread li)
xD
Plugin works great for me except for one small problem (well, major in my case).
Whenever users post code in between backticks, as is the preferred method with bbPress, the code is deleted upon submission of the post form.
The easiest way to sort out image size problems is to add this code to your .css file:
.threadpost img
{
width:100%;
}
it'll limit the width of the image to the width of the thread post area.
I have the same problem as greenshady, basically the plugin breaks code placed within backticks. This is quite a big problem as allowing users to post code snippets is very important, see below :)
So, does anyone have any information about whether a fix is being worked on?
Note, it is possible to enable images by hacking bb-includes/formatting-functions.php, changing the following function:
function bb_allowed_tags() {
$tags = array(
'a' => array(
'href' => array(),
'title' => array(),
'rel' => array()),
'blockquote' => array('cite' => array()),
'br' => array(),
'code' => array(),
'pre' => array(),
'em' => array(),
'strong' => array(),
'ul' => array(),
'ol' => array(),
'li' => array()
);
return apply_filters( 'bb_allowed_tags', $tags );
}
To this:
function bb_allowed_tags() {
$tags = array(
'a' => array(
'href' => array(),
'title' => array(),
'rel' => array()),
'blockquote' => array('cite' => array()),
'br' => array(),
'code' => array(),
'pre' => array(),
'em' => array(),
'img' => array(
'src' => array(),
'alt' => array()),
'strong' => array(),
'ul' => array(),
'ol' => array(),
'li' => array()
);
return apply_filters( 'bb_allowed_tags', $tags );
}
However, it is probably[?] not a wise idea to do so as I am pretty sure this will not provide any sanity checks -- meaning users could possibly use the image tag to call on malicious scripts etc.
Therefore, fixing this plugin would be a preferable option.
No, no, don't hack the core. There is no need.
Very easy to add tags in bbpress via plugin.
The full plugin probably breaks code sections because it tries to do it's own bad tag encoding. You can try a more direct method instead.
<?php
/*
Plugin Name: Allow Images (mini-mod)
*/
add_filter( 'bb_allowed_tags', 'allow_img_tag' );
function allow_img_tag( $tags ) {$tags['img'] = array('src' => array(), 'title' => array(), 'alt' => array()); return $tags;}
?>
.
try that instead - note it makes no attempt to verify images
There is also this alternative:
http://bbpress.org/forums/topic/code-backtick-bug#post-17962
http://code.google.com/p/llbbsc/wiki/HTMLTagAttributesValidatorPlugin"The easiest way to sort out image size problems is to add this code to your .css file:
.threadpost img
{
width:100%;
}
it'll limit the width of the image to the width of the thread post area. "
this is a great solution for large images, however it also stretches all smaller images to 100% use this instead
.threadpost img
{
max-width:100%;
}
that should leave all the smaller images alone and only limit those which exceed the posting area
hello,
how to add the slash at the end of img src?
i try this:
if ( preg_match_all('/<img(.+?)src=("|\')(.+?)\\2(.+?) />/i', $text, $matches, PREG_SET_ORDER ) )
but not effect.
/> is the normal end of a img src, please update the plugin :p
bye
is it possible/easily done to use some of the code for bb_attachments for setting permissions and apply it to this plugin? I don't want anyone lower than a mod linking images.
beernews, yes you can try changing this function
function allow_images_allowed_tags( $tags ) {
$tags['img'] = array('src' => array(), 'title' => array(), 'alt' => array());
return $tags;
}
to something like this (untested)
function allow_images_allowed_tags( $tags ) {
if (bb_current_user_can('moderate')) {
$tags['img'] = array('src' => array(), 'title' => array(), 'alt' => array());
}
return $tags;
}Thanks for the quick reply! It gets rid of the img tag but I am still able to post images as a member. I'll try to tweak it though I'm not exactly a programmer!
Awesome! That was easy.
I just added 'if (bb_current_user_can('moderate')) {'
and the ending "}" to the other two sections of code and it worked!
Hmm, after finally inviting another user, I realized that I somehow disallowed posting altogether for people that aren't mods. I corrected the error and while they can still post, they can again hotlink images.
I'll go through this file and learn every line of code so that I can report back!
Forgot to report back!
I realized that I was able to post images as admin by installing the admin can post anything plugin.
Just make sure to write up the code like <img src=URL of the image>
No need to have allow images installed.
When I input the code to include the image in a post, my image is surrounded by the post-form colour. The image is the only content in the post. Posts without images are surrounded by the post content colour. How can I change so that the image is surrounded by the post content colour, in this case white, instead of the post-form colour?
Using bbpress .9.0.2, with allow images .7.1
FYI, I was getting a 'cannot send headers' error. There was a blank space after the ?>
Also, to fix the whole annoying thing with it breaking my code tags? I commented out the following:
// remove_filter( 'pre_post', 'encode_bad' );
// add_filter( 'pre_post', 'allow_images_encode_bad', 9 );
// add_filter( 'pre_post', 'allow_images', 52 );Great work!
Great Plugin. Worked without any issues. I'm using .threadpost img { max-width:100%; } too to keep the template from breaking with large images.
You must log in to post.