buddypress / bp-attachments

BP Attachments is a BuddyPress component to help others deal with attachments
GNU General Public License v2.0
39 stars 12 forks source link

Introduce a filter to edit how the attached media is added to the activity content #82

Closed imath closed 1 year ago

imath commented 1 year ago

If you need to prepend the Medium to the activity content, you simply need to use the bp_attachments_activity_attach_media filter this way:

/**
 * Filter to prepend the Medium to the Activity text.
 *
 * @param string $content      The Activity text block with the appended Medium block.
 * @param string $text_block   The serialized Activity text block.
 * @param string $medium_block The serialized Medium block.
 * @return string The Activity text block with the prepended Medium block.
 */
function testovac_attachments_activity_prepend_media( $content, $text_block, $medium_block ) {
    return $medium_block . "\n" . $text_block;
}
add_filter( 'bp_attachments_activity_attach_media', 'testovac_attachments_activity_prepend_media', 10, 3 );

Fixes #81