WordPress.org

Forums

BuddyPress Activity Plus
[resolved] Add Image Size (7 posts)

  1. MeRuud
    Member
    Posted 2 years ago #

    Hi All,

    First of all; what a great plugin! It really does what it is supposed to do. I have been modifying it for a bit (mostly stylish) and right now I am stuck on trying to add an extra image size.

    The reason why I want to add this is so that there will be three image sizes in total: On the activity feed it shows the thubmnail, when you click the thumbnail you get the original, and third (which will be the newly added) when you go to the single activity entry it will show an enlarged thumbnail by default.

    So the code is pretty clear, and well organized (Thank you vebailovity, I think your the main developer?). But I have a difficult time finding where the "-bpfb" is being added to the picture.

    This is what I am planning to do, not sure if this will work. I am not a coder at all.

    Original class_bfbp_binder contains

    // Override thumbnail image size in wp-config.php
    		if (defined('BPFB_THUMBNAIL_IMAGE_SIZE')) {
    			list($tw,$th) = explode('x', BPFB_THUMBNAIL_IMAGE_SIZE);
    			$thumb_w = (int)$tw ? (int)$tw : $thumb_w;
    			$thumb_h = (int)$th ? (int)$th : $thumb_h;
    		}
    
    		$processed = 0;
    		foreach ($imgs as $img) {
    			$processed++;
    			if (BPFB_IMAGE_LIMIT && $processed > BPFB_IMAGE_LIMIT) break; // Do not even bother to process more.
    			if (preg_match('!^https?:\/\/!i', $img)) { // Just add remote images
    				$ret[] = $img;
    				continue;
    			}
    
    			$pfx = $bp->loggedin_user->id . '_' . preg_replace('/ /', '', microtime());
    			$tmp_img = realpath(BPFB_TEMP_IMAGE_DIR . $img);
    			$new_img = BPFB_BASE_IMAGE_DIR . "{$pfx}_{$img}";
    			if (@rename($tmp_img, $new_img)) {
    				image_resize($new_img, $thumb_w, $thumb_h, false, 'bpfbt');
    				$ret[] = pathinfo($new_img, PATHINFO_BASENAME);
    			}
    			else return false;
    		}

    Modified version class_bfbp_binder will add this to define size

    if (defined('BPFB_LARGE_IMAGE_SIZE')) {
    			list($tw,$th) = explode('x', BPFB_LARGE_IMAGE_SIZE);
    			$large_w = (int)$tw ? (int)$tw : $large_w ;
    			$large_h = (int)$th ? (int)$th : $large_h ;
    		}

    And the part which actually renames the images and resizes is (I assume). How would I add a second request to this for my second image? Just add another if (@rename statement?

    $pfx = $bp->loggedin_user->id . '_' . preg_replace('/ /', '', microtime());
    			$tmp_img = realpath(BPFB_TEMP_IMAGE_DIR . $img);
    			$new_img = BPFB_BASE_IMAGE_DIR . "{$pfx}_{$img}";
    			if (@rename($tmp_img, $new_img)) {
    				image_resize($new_img, $thumb_w, $thumb_h, false, 'bpfbt');
    				$ret[] = pathinfo($new_img, PATHINFO_BASENAME);
    			}

    http://wordpress.org/extend/plugins/buddypress-activity-plus/

  2. MeRuud
    Member
    Posted 2 years ago #

    Btw the only thing I would add to make this plugin a bit better is that when you upload it uploads it to the media library instead of a separate (unrecognized) directory. This way it is also being "bound" to a user (?right).

    Thanks for the help, and the great plugin!
    Ruud

  3. yzqiang
    Member
    Posted 2 years ago #

    I need it very much. I will try it. Thanks.

  4. ellbristow
    WPMU DEV Support Staff
    Posted 2 years ago #

    Hi there,

    We're just tidying up the support forums for our plugins and noticed this thread has not been marked as resolved. Do you still need assistance with this? If so let us know and we'll take a look for you, otherwise please tag the thread as resolved so that we know you are all fixed up! :)

    Thanks!

  5. MeRuud
    Member
    Posted 2 years ago #

    Yes please!
    I haven't been able to solve it yet, posted a question on Stack-overflow but no replies there either so far.

    Thanks

  6. ellbristow
    WPMU DEV Support Staff
    Posted 2 years ago #

    OK... I'm going to tag Ve to take a look at this because it's a little bit beyond my knowledge of the plugin... bear with us :)

  7. vebailovity
    Member
    Posted 2 years ago #

    Hello,

    You identified the portion of code responsible for this quite precisely, and to add another size you could just add another image_resize() call, using your second set of image sizes and, of course a different suffix (not bpfbt) so you're sure the two generated thumbnails won't overwrite each other. This is where the original thumbnail is actually generated, so you can try and use the same approach in adding the new size. Of course, you'll probably also want to add some context awareness to the images shortcode tag template so it actually makes use of the new image size. I hope this helps.

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