Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP External Group RSS FEEDS: Thumbnail Images


  • quigley05
    Participant

    @quigley05

    I know this plugin, BP External Group Blogs, has lost activity and support, however it’s the only plugin of it’s type and nearly works perfectly for what I’m wanting it to do! I have a couple, what seems to be simple, objectives:

    1. Thumbnail Images. What line of code needs to be added to bring thumbnail imagery into each post?

    2. Avatar removal. What code needs to be edited to remove the default avatars from post feeds?

    Thank you! Fingers crossed.

Viewing 9 replies - 1 through 9 (of 9 total)

  • Venutius
    Moderator

    @venutius

    Do you mean the group avatar?


    quigley05
    Participant

    @quigley05

    Correct. It currently just clicks out to the article it’s feeding.


    Venutius
    Moderator

    @venutius

    I don’t have a full answer, as I’m not entirely sure how the group avatar gets displayed using this code. But it’s line 226 of `includes/bp-groups-externalblogs.php that is creating the activity entry:

    $activity_action = sprintf( __( 'Blog: %s from %s in the group %s', 'bp-groups-externalblogs' ), '<a class="feed-link" href="' . esc_attr( $post['link'] ) . '">' . esc_attr( $post['title'] ) . '</a>', '<a class="feed-author" href="' . esc_attr( $post['blogurl'] ) . '">' . attribute_escape( $post['blogname'] ) . '</a>', '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' );

    My hacker workaround suggestion to you is to simply remove mention of the group, after all, if it’s being posted in the group activity, why mention the group at all, and this should remove the avatar too, as follows:

    $activity_action = sprintf( __( 'Blog: %s from %s', 'bp-groups-externalblogs' ), '<a class="feed-link" href="' . esc_attr( $post['link'] ) . '">' . esc_attr( $post['title'] ) . '</a>', '<a class="feed-author" href="' . esc_attr( $post['blogurl'] ) . '">' . attribute_escape( $post['blogname'] ) . '</a>' );


    quigley05
    Participant

    @quigley05

    Thanks. Unfortunately that specific change of code ignored the avatar completely and just removed the heading. See below for reference:

    Before:
    before

    After:
    after


    Venutius
    Moderator

    @venutius

    That’s strange, I don’t see an issue with the code, it certainly shuld be printing something.


    Venutius
    Moderator

    @venutius

    I’ve just tested it, works on my system


    Venutius
    Moderator

    @venutius

    Ah, I’ve just realised which group avatar you are talking about, not the one I was thinking. in my system I was getting a group avatar right beside the group name, scrap my code.

    That’s a function of BuddyPress, not of BP External Group Blocgs I reckon, Every activity post in the group will get that, not just the RSS feed items.


    Venutius
    Moderator

    @venutius

    One option would be to disable group avatars altogether maybe?

    The other issue is that BP External Blogs has a big problem in group creation, it’s throwing a lot of errors now I’ve got it running. It’s won’t allow me to create a new group when it’s running.


    quigley05
    Participant

    @quigley05

    Hmm.. there is the following code that looks suspect in the plugin:

    /* Fetch an existing activity_id if one exists. */
    			if ( function_exists( 'bp_activity_get_activity_id' ) )
    				$id = bp_activity_get_activity_id( array( 'user_id' => false, 'action' => $activity_action, 'component' => $bp->groups->id, 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash( $post['blogurl'] ) ) );

    Anything here stand out as a possibility?

    Also, regarding the thumbnail integration, I’ve been trying to figure out what the necessary fetching rules are to gather that data? The below is clearly where it goes, I just have no clue how to properly integrate this..

    	/* Set the visibility */
    		$hide_sitewide = ( 'public' != $group->status ) ? true : false;
    
    		foreach ( (array) $group_blogs as $feed_url ) {
    
    			$rss = fetch_feed( trim( $feed_url ) );
    
    			if (!is_wp_error($rss) ) {
    				$maxitems = $rss->get_item_quantity( 10 );
    				$rss_items = $rss->get_items( 0, $maxitems );
    
    				foreach ( $rss_items as $item ) {;
    					$key = $item->get_date( 'U' );
    					$items[$key]['title'] = $item->get_title();
    					$items[$key]['subtitle'] = $item->get_title();
    					//$items[$key]['author'] = $item->get_author()->get_name();
    					$items[$key]['blogname'] = $item->get_feed()->get_title();
    					$items[$key]['link'] = $item->get_permalink();
    					$items[$key]['blogurl'] = $item->get_feed()->get_link();
    					$items[$key]['description'] = $item->get_description();
    					$items[$key]['source'] = $item->get_source();
    					$items[$key]['copyright'] = $item->get_copyright();
    				}
    			}
    		}
    
    		if ( $items ) {
    			ksort( $items );
    			$items = array_reverse( $items, true );
    		} else {
    			return false;
    		}
    
    		/* Record found blog posts in activity streams */
    		foreach ( (array) $items as $post_date => $post ) {
    
    			$activity_action = sprintf( __( '%s from %s in %s', 'bp-groups-externalblogs' ), '<a class="feed-link" href="' . esc_attr( $post['link'] ) . '" target="_blank">' . esc_attr( $post['title'] ) . '</a>', '<a class="feed-author" href="' . esc_attr( $post['blogurl'] ) . '" target="_blank">' . attribute_escape( $post['blogname'] ) . '</a>', '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' );
    
    			$activity_content = '<div>' . strip_tags( bp_create_excerpt( $post['description'], 175 ) ) . '</div>';
    			$activity_content = apply_filters( 'bp_groupblogs_activity_content', $activity_content, $post, $group );
    			/* Fetch an existing activity_id if one exists. */
    			if ( function_exists( 'bp_activity_get_activity_id' ) )
    				$id = bp_activity_get_activity_id( array( 'user_id' => false, 'action' => $activity_action, 'component' => $bp->groups->id, 'type' => 'exb', 'item_id' => $group_id, 'secondary_item_id' => wp_hash( $post['blogurl'] ) ) );
    
    			/* Record or update in activity streams. */
    			groups_record_activity( array(
    				'id' => $id,
    				'user_id' => false,
    				'action' => $activity_action,
    				'content' => $activity_content,
    				'primary_link' => $item->get_link(),
    				'type' => 'exb',
    				'item_id' => $group_id,
    				'secondary_item_id' => wp_hash( $post['blogurl'] ),
    				'recorded_time' => gmdate( "Y-m-d H:i:s"),
    				'hide_sitewide' => $hide_sitewide
    			) );
    		}
    
    		return $items;
    	}
Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar