Skip to:
Content
Pages
Categories
Search
Top
Bottom

Allowing inline images uploads in posts?

  • @ben_allison

    Member

    The bb-attachments plugin doesn’t work any more with current version of bbPress.

    Is there are reasonable solution to allow users to insert images (upload, not just add tag) into their posts?

Viewing 25 replies - 1 through 25 (of 41 total)
  • @anointed

    Participant

    If you are using WordPress 3.3 and the latest bbPress (I use the nightly download), then you can turn on the tinymce editor instead of the standard textfield input for creating topics and replies.

    You would then need to grant permission to the different roles that you want to allow to insert images, either via links or the upload system.

    There are user role plugins that can help with this which are actually built for WordPress, but work for bbPress just fine.

    Keep in mind that it’s not usually good practice to allow regular users to upload whatever they want into your media system.

    @ben_allison

    Member

    Thanks!

    It’s a closed forum so I’m ok with people uploading what they want.

    I just can’t seem to find the option to turn on tinymce for replies! It’s some php magic or is there an actual option in the admin somewhere?

    @anointed

    Participant

    Sure, in settings -> forums check the last option.

    http://screensnapr.com/v/FinWe0.png

    Does require WordPress 3.3 and latest bbPress for this option to show up.

    @ben_allison

    Member

    Weird! I don’t have that option.

    I’m on bbPress 2.0.2 Do you mean the 2.1 beta?

    @anointed

    Participant

    Yeah I would try the 2.1 beta and also you HAVE to be running WordPress 3.3 as that is where the new editor function was introduced.

    @jeaz

    Participant

    Hey,

    I’m confused here, how do I enable the users to insert images?

    I’m using 2.1 and but even me as an administrator don’t see add any image upload or insert options when posting.

    EDIT: To clarify, I can see the options when posting from the admin section, but not from the forums.

    @steilenhang

    Participant

    With todays versions (WP 3.4.1 and BBpress 2.1.2), is this really possible? I have been waiting for a “attachments upload function” ever since BBpress 2.0. I am still using the old BBpress and CK‘s attachments plugin.

    If this is possible, it’s time to upgrade 🙂

    PS: I heard that BBpress 2.2 will have this feature built-in. Would it be wice to wait for that instead?

    @raphaeljeger

    Participant

    I use the absolute newest version of WP and BP (3.4.2 and 2.2.2) and can’t upload images directly in the editor and didn’t find a plugin for doing it (uploading, display them inline etc.)

    Is there really no solution? If that’s the case I’ll have to switch to another forum because it’s absolutely unusable for my case 🙁

    @jaredatch

    Member

    There is a plugin that enables attachments – https://wordpress.org/extend/plugins/gd-bbpress-attachments/, however past that currently there is no other method. It’s certainly on the list for core, we just haven’t gotten to it yet.

    @raphaeljeger

    Participant

    Thank you Jared…
    A real bummer to me. I highly appreciate all your work and like the system apart fron that, but no inline images = real big bummer 🙁 I can’t even imagine having a forum w/o it…

    @raphaeljeger

    Participant

    Jared, I’m almost finished with inline image posting using a tinyMCE plugin. Wanna know how I did it?

    @sunriseweb

    Participant

    @RaphaelJeger I want to know!! 🙂

    https://wordpress.org/extend/plugins/gd-bbpress-attachments/ works but doesn’t help with inline attachments, and the regular WordPress tinyMCE settings are not applied to the bbPress editor.

    @jaredatch

    Member

    The thing that makes inline images tough is non-admin users cannot use the tag and shortcodes are not an option.

    Currently there is an issue on trac (#1916) that would make it where img tags do not get filtered out. Once that’s done it would open the gate for plugins to handle inline images pretty easily.

    @brodskis

    Participant

    is there any resolution to this? I’ve been searching for the last few days either for a way to make members profiles and forums more visaul, enabling portfolios etc or for a reay built theme which will enable this.

    Any advice much appresciated

    @caesarhills

    Participant

    Seems it’s a common request: I’ve also spent last days looking for a way to upload inline images in bbpress forum but still with no luck.
    Are there any updates for this option? It is essential for my forum, cause it should work as a blog where forum’s members open their threads as posts, meaning, text and images: nobody would click over an attacchments, so I need inline images.
    I’ve also installed buddypress and for what concern the admin of the forum is possible with the (media button ) to upload inline images and videos, but as I said it works just for the admin when opening a new thread: after that, there s no way even for the admin to add media in his replies

    @atomicadam

    Participant

    Any luck on this? This is something our forum users are requesting as well, and kind of seems like a no brainer default feature of a forum plugin.

    Currently, when user is a “participant” and try to upload an image via the media uploader, this is the error they get “You don’t have permission to attach files to this post.”

    Viewing the “participant” permissions via Roles plugin, upload image is checked off, while unfiltered is not. But I can’t alter these settings.

    What gives?

    @palmdoc

    Participant

    This works for me :

    1) Add this to function.php in your child theme

    via http://bavotasan.com/2014/add-media-upload-button-to-bbpress/

    Open up your functions.php file and add the following snippet to get it working:

    add_filter( 'bbp_after_get_the_content_parse_args', 'bavotasan_bbpress_upload_media' );
    /**
     * Allow upload media in bbPress
     *
     * This function is attached to the 'bbp_after_get_the_content_parse_args' filter hook.
     */
    function bavotasan_bbpress_upload_media( $args ) {
    	$args['media_buttons'] = true;
    
    	return $args;
    }
    

    So now you have the Add Media button in the posting

    2) What you need now is to fine tune the user capabilities so that not only administrators but normal users can upload media direct to the form post using the Add Media button

    I am using the Capability Manager Enhanced plugin

    https://wordpress.org/plugins/capability-manager-enhanced

    I guess you could use a Custom user type (e.g. clone the normal participants) to experiment. Later on you could edit all your users and convert them to this Custom user type

    Check the ability to:

    a) Upload files
    b) Unfiltered HTML

    for this Custom user type

    I guess it comes with risks but it has the benefits of direct Media upload to the bbPress forum

    It’s not only images but other media e.g. PDF (which works nicely with thhe Google Doc Embedder Plugin

    @palmdoc

    Participant

    Forgot to add that the above I’d for the stock bbPress installation and does not need the tinyMice editor

    @caesarhills

    Participant

    Brillant indeed 🙂
    Just to be sure: when saying Media in the posting, it means it can upload photos, videos stored in our pc folders and show them live on the forum’s post? or just an attacchment?

    @palmdoc

    Participant

    Yes @caesarhills, it’s inline images live in your forum post and not just an attachment 🙂
    There is an issue on the size limitation for upload but that may be a server restriction I think.
    Anyway you can always warn your users to resize the images before upload.
    I am trying various “resize images on upload” plugins but so far none seem to work properly

    @stagger-lee

    Participant

    I just write this on trac. Needs to be restricted for users to see other attachments, they did not uploaded.

    function filter_my_attachments( $wp_query ) {
        if (is_admin() && ($wp_query->query_vars['post_type'] == 'attachment')) {
            if ( !current_user_can( 'activate_plugins' ) ) {
                global $current_user;
                $wp_query->set( 'author', $current_user->id );
            }
        }
    }
    add_filter('parse_query', 'filter_my_attachments' );
    
    add_filter( 'bbp_after_get_the_content_parse_args', 'tp_bbpress_upload_media' );
     
    function tp_bbpress_upload_media( $args ) {
    $args['media_buttons'] = true;
     
    return $args;
    }

    @stagger-lee

    Participant

    Set a maximum upload count for users on a specific user role

    add_filter( 'wp_handle_upload_prefilter', 'limit_uploads_for_user_roles' );
     
    function limit_uploads_for_user_roles( $file ) {
      $user = wp_get_current_user();
      // add the role you want to limit in the array
      $limit_roles = array('contributor');
      $filtered = apply_filters( 'limit_uploads_for_roles', $limit_roles, $user );
      if ( array_intersect( $limit_roles, $user->roles ) ) {
        $upload_count = get_user_meta( $user->ID, 'upload_count', true ) ? : 0;
        $limit = apply_filters( 'limit_uploads_for_user_roles_limit', 10, $user,$upload_count, $file );
        if ( ( $upload_count + 1 ) > $limit ) {
          $file['error'] = __('Upload limit has been reached for this account!','yourtxtdomain');
        } else {
          update_user_meta( $user->ID, 'upload_count', $upload_count + 1 );
        }
      }
      return $file;
    }

    This action will fire when user delete attachment

    add_action('delete_attachment', 'decrease_limit_uploads_for_user');
    function decrease_limit_uploads_for_user( $id ) {
       $user = wp_get_current_user();
       // add the role you want to limit in the array
       $limit_roles = array('contributor');
       $filtered = apply_filters( 'limit_uploads_for_roles', $limit_roles, $user );
       if ( array_intersect( $limit_roles, $user->roles ) ) {
         $post = get_post( $id);
         if ( $post->post_author != $user->ID ) return;
         $count = get_user_meta( $user->ID, 'upload_count', true ) ? : 0;
         if ( $count ) update_user_meta( $user->ID, 'upload_count', $count - 1 );
       }
    }

    @stagger-lee

    Participant

    This seems to work, just tested. Adjust after need.
    Limit user upload by KB size:

    add_filter('wp_handle_upload_prefilter', 'f711_image_size_prevent');
    function f711_image_size_prevent($file) {
    
        // get filesize of upload
        $size = $file['size'];
        $size = $size / 1024; // Calculate down to KB
    
        // get imagetype of upload
        $type = $file['type'];
        $is_image = strpos($type, 'image');
    
        // set sizelimit
        $limit = 700; // Your Filesize in KB
    
        // set imagelimit
        $imagelimit = 7;
    
        // set allowed imagetype
        $imagetype = 'image/jpeg';
    
        // query how many images the current user already uploaded
        global $current_user;
        $args = array(
            'orderby'         => 'post_date',
            'order'           => 'DESC',
            'numberposts'     => -1,
            'post_type'       => 'attachment',
            'author'          => $current_user->ID,
        );
        $attachmentsbyuser = get_posts( $args );
    
        if ( ( $size > $limit ) && ($is_image !== false) ) { // check if the image is small enough
            $file['error'] = 'Image files must be smaller than '.$limit.'KB';
        } elseif ( $type != $imagetype ) { // check if image type is allowed
            $file['error'] = 'Image must be ' . $imagetype . '.';
        } elseif ( count( $attachmentsbyuser ) >= $imagelimit ) { // check if the user has exceeded the image limit
            $file['error'] = 'Image limit of ' . $imagelimit . ' is exceeded for this user.';
        }
        return $file;
    
    }

    @bayanassaf

    Participant

    You can add the following code in your functions.php file:

    add_action(‘media_buttons’, ‘ml_pre_media_buttons’, 1);
    add_action(‘media_buttons’, ‘ml_post_media_buttons’, 20);
    function ml_pre_media_buttons($editor_id) {
    if (!$editor_id == ‘bbp_reply_content’)
    return;

    $GLOBALS[‘post_temp’] = $GLOBALS[‘post’];
    $GLOBALS[‘post’] = null;
    }
    function ml_post_media_buttons($editor_id) {
    if (!$editor_id == ‘bbp_reply_content’)
    return;

    $GLOBALS[‘post’] = $GLOBALS[‘post_temp’];
    }

    @bayanassaf

    Participant

    Hello Ben,

    Add this function to your functions.php file:

    add_filter( ‘bbp_after_get_the_content_parse_args’, ‘bavotasan_bbpress_upload_media’ );
    /**
    * Allow upload media in bbPress
    *
    * This function is attached to the ‘bbp_after_get_the_content_parse_args’ filter hook.
    */
    function bavotasan_bbpress_upload_media( $args ) {
    $args[‘media_buttons’] = true;

    return $args;
    }

    This adds an “Add media” button to the write panel.

Viewing 25 replies - 1 through 25 (of 41 total)
  • You must be logged in to reply to this topic.
Skip to toolbar