BP_REST_Media_Endpoint::bp_gif_data_update_rest_field_callback( object $object, object $value, string $attribute )

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

Description

Parameters

$object

(Required) The BuddyPress component's object that was just created/updated during the request. (in this case the BP_Activity_Activity object).

$value

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

$attribute

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

Return

(object)

Source

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

2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
protected function bp_gif_data_update_rest_field_callback( $object, $value, $attribute ) {
 
    if ( 'media_gif' !== $attribute || empty( $object ) ) {
        return $value;
    }
 
    $still = $object['url'];
    $mp4   = $object['mp4'];
 
    if ( ! empty( $still ) && ! empty( $mp4 ) ) {
 
        $still = bp_media_sideload_attachment( $still );
        $mp4   = bp_media_sideload_attachment( $mp4 );
 
        bp_activity_update_meta(
            $value->id,
            '_gif_data',
            array(
                'still' => $still,
                'mp4'   => $mp4,
            )
        );
 
        bp_activity_update_meta(
            $value->id,
            '_gif_raw_data',
            array(
                'still' => $still,
                'mp4'   => $mp4,
            )
        );
    }
 
    return $value;
}

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.