Filter: cloudinary_asset_payload

apply_filters( 'cloudinary_asset_payload', $asset, $data ) → {array}

Filter the asset payload.
Parameters:
Name Type Description
$asset array The asset payload.
$data array The raw data from the request.
Since:
  • 3.1.3
Source:
Returns:
Type
array
Example
<?php

// Extend Cloudinary support for extra data.
// Contextual metadata is passed by default.
add_filter(
   'cloudinary_asset_payload',
   static function ( $asset, $payload ) {
       // The structured keys on Cloudinary to use in WordPress.
       $key = 'structured_key';

       // Structural metadata. Beware of key collision with contextual metadata.
       if ( ! empty ( $payload['asset']['metadata'][ $key ] ) ) {
           // The sanitize function to use should be adequate to the data type.
           $asset['meta'][ $key ] = sanitize_text_field( $payload['asset']['metadata'][ $key ] );
       }

       // The Cloudinary tags.
       if ( ! empty ( $payload['asset']['tags'] ) ) {
           $asset['tags'] = array_map( 'sanitize_text_field', $payload['asset']['tags'] );
       }

       return $asset;
   },
   10,
   2
);