BP_REST_Media_Endpoint::bp_gif_data_get_rest_field_callback_messages( array $message )

The function to use to get medias gif for the Messages REST Field.

Description

Parameters

$message

(Required) The message value for 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_messages( $message ) {

		$message_id = $message['id'];

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

		$gif_data = bp_messages_get_meta( $message_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'] );

		$retval = array(
			'preview_url' => $preview_url,
			'video_url'   => $video_url,
			'rendered'    => $this->bp_rest_media_message_embed_gif( $message_id ),
		);

		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.