cp_add_cats_and_tags_to_attachment_for_js( $response,  $attachment,  $meta )

Adds media categories and media post tags to the array of attachment details.


Return

(array)


Source

File: wp-admin/includes/media.php

function cp_add_cats_and_tags_to_attachment_for_js( $response, $attachment, $meta ) {
	$cat_terms = get_terms(
		array(
			'taxonomy' => 'media_category',
		)
	);

	$media_cats = array();
	if ( ! empty( $cat_terms ) ) {
		$media_cats = get_terms(
			array(
				'taxonomy'   => 'media_category',
				'object_ids' => $attachment->ID,
				'fields'     => 'slugs',
			)
		);
	}

	/**
	 * Filters the media categories included in the array of attachment details.
	 *
	 * @since CP-2.3.0
	 *
	 * @return array  $media_cats  Media categories
	 */
	$response['media_cats'] = apply_filters( 'cp_media_cats_for_js', $media_cats );

	$tag_terms = get_terms(
		array(
			'taxonomy' => 'media_post_tag',
		)
	);

	$media_tags = array();
	if ( ! empty( $tag_terms ) ) {
		$media_tags = get_terms(
			array(
				'taxonomy'   => 'media_post_tag',
				'object_ids' => $attachment->ID,
				'fields'     => 'slugs',
			)
		);
	}

	/**
	 * Filters the media tags included in the array of attachment details.
	 *
	 * @since CP-2.3.0
	 *
	 * @return array  $media_tags  Media tags
	 */
	$response['media_tags'] = apply_filters( 'cp_media_tags_for_js', $media_tags );

	return $response;
}

Changelog

Changelog
Version Description
CP-2.3.0 Introduced. CP-2.3.0