BP_REST_Media_Endpoint::bp_gif_data_get_rest_field_callback( BP_Activity_Activity $activity, string $attribute )

The function to use to get gif data of the activity REST Field.

Description

Parameters

$activity

(BP_Activity_Activity) (Required) Activity Array.

$attribute

(string) (Required) The REST Field key used into the REST response.

Return

(string) The value of the REST Field to include into the REST response.

Source

File: bp-media/classes/class-bp-rest-media-endpoint.php

	protected function bp_gif_data_get_rest_field_callback( $activity, $attribute ) {
		$activity_id = $activity['id'];

		if ( empty( $activity_id ) ) {
			return;
		}

		$gif_data = bp_activity_get_meta( $activity_id, '_gif_data', true );

		if ( empty( $gif_data ) ) {
			return;
		}

		$preview_url   = wp_get_attachment_url( $gif_data['still'] );
		$video_url     = wp_get_attachment_url( $gif_data['mp4'] );
		$rendered_data = ( function_exists( 'bp_media_activity_embed_gif_content' ) ? bp_media_activity_embed_gif_content( $activity_id ) : '' );

		$retval = array(
			'preview_url' => $preview_url,
			'video_url'   => $video_url,
			'rendered'    => preg_replace( '/[\r\n]*[\t]+/', '', $rendered_data ),
		);

		return $retval;
	}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.