BP_REST_Media_Endpoint::bp_gif_data_update_rest_field_callback_messages( object $object, object $value )

The function to use to update the medias’s value of the activity REST Field.

Description

Parameters

$object

(object) (Required) Message as a object.

$value

(object) (Required) The value of the REST Field to save.

Source

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

	protected function bp_gif_data_update_rest_field_callback_messages( $object, $value ) {

		$still      = ( ! empty( $object ) && array_key_exists( 'url', $object ) ) ? $object['url'] : '';
		$mp4        = ( ! empty( $object ) && array_key_exists( 'mp4', $object ) ) ? $object['mp4'] : '';
		$message_id = $value->id;

		if ( ! empty( $still ) && ! empty( $mp4 ) ) {

			$still = bp_media_sideload_attachment( $still );
			$mp4   = bp_media_sideload_attachment( $mp4 );

			$gdata = array(
				'still' => $still,
				'mp4'   => $mp4,
			);

			bp_messages_update_meta( $message_id, '_gif_data', $gdata );
			$gif_data          = $gdata;
			$gif_data['saved'] = true;
			bp_messages_update_meta( $message_id, '_gif_raw_data', $gif_data );
		}
	}

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.