Skip to:
Content
Pages
Categories
Search
Top
Bottom

remove certain thumbnails from activity stream

  • I’ve a site which grabs a fairly large number of submitted blog feeds for syndication. They come from all over – wordpress.com, blogger, individual blogs on various platforms. Recently an issue has arisen where in a lot of feeds the first image is a tweetmeme or a stats tracker. Since we are pulling the first image and showing it at 150px wide, this looks awful.

    We can individually contact those submitting feeds to resolve this, but it’s like playing whack a mole, and I’d prefer to somehow filter them out. I am doing this in the standard WordPress pages within a function that grabs the first image from the feed, then filters out those containing certain strings – ‘api’, ‘stats’. ‘tracker’ etc. I’m trying to figure out how to do it here.

    I’ve located the function that shows the thumbnail – in shortened version below:

    function bp_activity_thumbnail_content_images( $content ) {
    preg_match_all( ‘/]*>/Ui’, $content, $matches );
    $content = preg_replace(‘/]*>/Ui’, ”, $content );

    if ( !empty( $matches ) ) {
    /** —- stuff about image size —*/

    if ( !empty( $src ) ) {
    /** —- stuff about image size —*/

    $content = ‘' . __( 'Thumbnail', 'buddypress' ) . '‘ . $content;
    }
    }

    return apply_filters( ‘bp_activity_thumbnail_content_images’, $content, $matches );
    }

    I’ve made some attempts at a filter, but I am going nowhere. Basically I don’t really know what I am doing, which is probably stating the blindingly obvious.

    function lose_rubbish_images ($src) {
    if(stristr($src, ‘tracker’)) {
    $content = ”;
    } elseif(stristr($src, ‘api’)) {
    $content = ”;
    } elseif(stristr($src, ‘stats’)) {
    $content = ”;
    } elseif(stristr($src ‘statistics’)) {
    $content = ”;
    }

    }
    add_filter(‘bp_activity_thumbnail_content_images’,’lose_rubbish_images’);

    Can anyone point me in the right direction?

  • The topic ‘remove certain thumbnails from activity stream’ is closed to new replies.
Skip to toolbar