Modify or add Image Used In context text in the Media Library Meta Box.

/**
* Filter image used in context.
* Used in /3rd-party/woocommerce.php for WooCommerce related images.
*
* @since 4.8
*
* @param $used_in_text (array) Descriptions for the context where the image is used in.
*/
$used_in_text = apply_filters( 'iaffpro_image_used_in_text', $used_in_text );
Used internally to add WooCommerce related context text. $used_in_text is an associative array and the array keys must match the array key used in $posts array.
Refer iaffpro_get_posts_by_attachment_id for a complete picture.
Example Usage
Let’s take the same example of Listings from iaffpro_get_posts_by_attachment_id‘s documentation.
To add a context text in the Media Library meta box, the code will look like below.
/**
* Add Listings related image used in text.
*
* @link https://imageattributespro.com/codex/iaffpro_image_used_in_text/
*
* @param $used_in_text (array) Descriptions for the context where the image is used in.
*
* @return $used_in_text (array) Descriptions with Listings related context added to it.
*/
function prefix_iap_my_listings_used_in_text( $used_in_text ) {
$used_in_text[ '05_my_listings' ] = __( '(as Listings main image)', 'auto-image-attributes-pro' );
return $used_in_text;
}
add_filter( 'iaffpro_image_used_in_text', 'prefix_iap_my_listings_used_in_text' );
Note that, 05_my_listings is the same array key that we used with the iaffpro_get_posts_by_attachment_id filter.