Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/17/2022 11:07:21 AM (22 months ago)
Author:
imath
Message:

Turn blog post’s activity featured image into a clickable link

Props sbrajesh

See #8052

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-functions.php

    r13215 r13298  
    34613461    );
    34623462
     3463    $post_url = '';
    34633464    // Get the WP_Post object if this activity type is a blog post.
    34643465    if ( $activity['type'] === 'new_blog_post' ) {
    3465         $content = get_post( $activity['secondary_item_id'] );
     3466        $content  = get_post( $activity['secondary_item_id'] );
     3467        $post_url = $content->guid;
    34663468    }
    34673469
     
    34913493     */
    34923494    $args = apply_filters( 'bp_activity_create_summary_extractor_args', $args, $content, $activity, $extractor );
    3493 
    34943495
    34953496    // Extract media information from the $content.
     
    35903591    } elseif ( $use_media_type === 'images' ) {
    35913592        $extracted_media_url = isset( $extracted_media['url'] ) ? $extracted_media['url'] : '';
    3592         $summary .= sprintf( ' <img src="%s">', esc_url( $extracted_media_url ) );
     3593
     3594        if ( $post_url ) {
     3595            $summary .= sprintf( '<a href="%1$s" class="activity-post-featured-image"><img src="%2$s"></a>', esc_url( $post_url ), esc_url( $extracted_media_url ) );
     3596        } else {
     3597            $summary .= sprintf( ' <img src="%s">', esc_url( $extracted_media_url ) );
     3598        }
    35933599    } elseif ( in_array( $use_media_type, array( 'audio', 'videos' ), true ) ) {
    35943600        $summary .= PHP_EOL . PHP_EOL . $extracted_media['original'];  // Full shortcode.
Note: See TracChangeset for help on using the changeset viewer.