do_action( 'cloudinary_download_asset', $asset, $return )
Action for the downloaded assets from Cloudinary Media Library.
Parameters:
Name | Type | Description |
---|---|---|
$asset |
array | The default filters. |
$return |
array | The return payload. |
- Since:
- 3.1.3
- Source:
Example
<?php
add_action(
'cloudinary_download_asset',
static function ( $asset ) {
// Store metadata. Contextual and Structured metadata should be similar.
$key = 'metadata_key';
if ( ! empty( $asset['meta'][ $key ] ) && ! empty( $asset['attachment_id'] ) && 'attachment' === get_post_type( $asset['attachment_id'] ) ) {
update_post_meta( $asset['attachment_id'], $key , $asset['meta'][ $key ] );
}
// Store the tags. The taxonomy needs to be assigned to the post type.
if ( ! empty( $asset['tags'] ) && ! empty( $asset['attachment_id'] ) && 'attachment' === get_post_type( $asset['attachment_id'] ) ) {
wp_set_post_terms(
$asset['attachment_id'],
$asset['tags']
);
}
}
);