BuddyPress Activity Plus
[resolved] I have a solution to reduce images uploaded with Activity Plus (3 posts)

  1. GearMX
    Posted 2 years ago #

    Hi –

    The BuddyPress Activity Plus plugin is a must have add-on for BuddyPress in my opinion. However, due to its current design, it allows uploads of any image size that stays there. That means that a user can upload a 10MB image file and it will stay on your server as a 10MB file in the ‘bpfb’ folder. You can edit the Activity Plus code to limit the upload size, but this will soon become a massive hassle for users to reduce file sizes on their own (especially if a user wants to snap a shot with their mobile phone and upload to the activity stream). Here is my current solution:

    1) Install ImageMagick on your server
    2) Set up a cron job with the following command: cd “public_html/wp-content/uploads/bpfb/” && mogrify -strip -resize 800×800\> *.jpeg *.jpg
    (This will look at the directory and resize all jpeg images to 800×800 and not increase (blow up) images that are smaller).

    Works perfect, with one drawback: This solution will keep re-compressing files that have already been resized)… So if I set cron to resize once a week, it will recompress the file 52 times a year. In my situation I don’t really mind, but to make this solution better, I am working on a PHP script to SKIP files that have already been resized and re-compressed… but this is the solution I’m using right now and it works. If someone wants to help & co-build a PHP script with me please let me know (or if someone has a better overall solution)


  2. GearMX
    Posted 2 years ago #

    Another solution which is easier and works perfect (but you lose the lightbox feature)

    1) Increase the thumbnail size by adding this line to your wp-config file: define('BPFB_THUMBNAIL_IMAGE_SIZE', '640x640');
    (I've chosen 640x640 for the maximum thumbnail size, since lightbox is lost)

    2) Go to your plugins\buddypress-activity-plus\lib\forms folder and edit the images_tag_template.php file and delete this section: " class="<?php echo $use_thickbox; ?>" rel="<?php echo $rel;?>" <?php echo $target; ?> >
    (This will restrict opening your original uploaded image in a lightbox when you click on it - this is important since you will be deleting the original in the next step)

    3) Lastly, setup a cron, maybe once a week, to delete all files over a certain size in the bpfb folder (this is the folder where all the uploaded & thumbnail images are stored)

    I've set my cron to delete all images over 150kb. Here is the command line:
    find public_html/wp-content/uploads/bpfb/* -size +153600c -type f -delete

    (note: 153600c is bits, which is 150kb)

  3. J K
    WPMU DEV Support Staff
    Posted 2 years ago #

    Hi there @GearMX,

    I hope you are well today.

    Thanks for sharing your solution for this with everyone! I'm sure other users of the plugin will find it most helpful :)

    Thanks again! Hope you have a great weekend :)

    Kind Regards

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • BuddyPress Activity Plus
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.