iaffpro_custom_attribute_tag_category_names

The default output of %category% custom attribute tag of Image Attributes Pro is the first category associated with a post. If a post has multiple categories, only one of them will be used while generating image attributes.

This filter can be used to modify the output of %category% custom attribute tag.

/**
 * Filter the list of categories returned by %category% custom attribute tag. 
 * Default value is first category name.
 * 
 * @since 3.0
 * 
 * @param $categories[0] (string) The first category available. This is the default value.
 * @param $categories (array) Contains the names of all categories associated with $parent_post_id.
 */
return apply_filters( 'iaffpro_custom_attribute_tag_category_names', $categories[0], $categories );

Example Usage

In the following example, the output is modified using the filter. Once the code is applied (for example when added to functions.php of active theme), %category% will output a comma separated list of categories when a post has multiple categories.

/**
 * Generate a comma separated list of categories to be used as image attributes.
 * This modifies the output generated by %category% custom attributes tag in Image Attributes Pro.
 * 
 * @link https://imageattributespro.com/codex/iaffpro_custom_attribute_tag_category_names/
 * 
 * @param $first_category (string) The first category available.
 * @param $categories (array) Contains the names of all categories associated with given post.
 * 
 * @return (string) Comma separated list of all categories.
 */
function prefix_iap_add_all_categories_in_custom_attribute_tag_category( $first_category, $categories ) {

    // Returns all categories as a comma separated list. 
    return implode( ',', $categories );
}
add_filter( 'iaffpro_custom_attribute_tag_category_names', 'prefix_iap_add_all_categories_in_custom_attribute_tag_category', 10, 2 );

Related: iaffpro_custom_attribute_tag_tag_names