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

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

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

Example Code

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), %tag% will output a comma separated list of tags when a post has multiple tags.

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

    // Returns all tags as a comma separated list. 
    return implode( ',', $tags );
add_filter( 'iaffpro_custom_attribute_tag_tag_names', 'prefix_iap_add_all_tags_in_custom_attribute_tag_tag', 10, 2 );

Related: iaffpro_custom_attribute_tag_category_names

Was this article helpful?
Yes, thanks! 👍Not really 👎