{"id":541,"date":"2019-01-05T04:53:54","date_gmt":"2019-01-04T23:23:54","guid":{"rendered":"https:\/\/imageattributespro.com\/?post_type=codex&p=541"},"modified":"2021-06-18T01:01:55","modified_gmt":"2021-06-17T19:31:55","slug":"iaffpro_image_attributes","status":"publish","type":"codex","link":"https:\/\/imageattributespro.com\/codex\/iaffpro_image_attributes\/","title":{"rendered":"iaffpro_image_attributes"},"content":{"rendered":"
Filter the generated image attributes before they are used by the bulk updater. <\/p>
\/**\n * Filter generated image attributes\n * \n * @param $attributes \t\t(array) Associative array of image attributes.\n * @param $image_id \t\t(int) ID of the current image. \n * @param $parent_post_id\t(int) ID of the post the image is inserted into. 0 for images not attached to a post. \n * \n * @since 1.3\n *\/\n$attributes = apply_filters( 'iaffpro_image_attributes', $attributes, $image_id, $parent_post_id );<\/code><\/pre>The $attributes<\/code> is an associative array with the following array keys and values. <\/p>$attributes['title']<\/code> containing the image title.<\/li>$attributes['caption']<\/code> containing the image caption.<\/li>$attributes['description']<\/code> containing the description.<\/li>$attributes['alt_text']<\/code> containing the image alt text.<\/li><\/ul>Example Usage<\/h2>
An example of using the filter to modify the generated image title, caption, description and alt text. Add this to the functions.php<\/code> of the active theme. <\/p>\/**\n * Modify image attributes generated by Image Attributes Pro\n *\n * @param $attributes \t\t(array) Associative array of image attributes.\n * @param $image_id \t\t(int) ID of the current image.\n * @param $parent_post_id\t(int) ID of the post the image is inserted into. 0 for images not attached to a post.\n * \n * @author Arun Basil Lal\n * @link https:\/\/imageattributespro.com\/codex\/iaffpro_image_attributes\/\n *\/\n function prefix_iap_modify_image_attributes( $attributes, $image_id, $parent_post_id ) {\n\t\n\t$attributes['title'] = 'Your Title';\n\t$attributes['caption'] = 'Prefix For Caption - ' . $attributes['caption'];\n\t$attributes['description'] = 'Custom Description';\n\t$attributes['alt_text'] = $attributes['alt_text'] . ' - Post Fix To Alt Text';\n\t\n\treturn $attributes;\n}\nadd_filter( 'iaffpro_image_attributes', 'prefix_iap_modify_image_attributes', 10, 3 );<\/code><\/pre>","protected":false},"excerpt":{"rendered":"Filter the generated image attributes before they are used by the bulk updater. The $attributes is an associative array with the following array keys and values. $attributes[‘title’] containing the image title. $attributes[‘caption’] containing the image caption. $attributes[‘description’] containing the description. $attributes[‘alt_text’] containing the image alt text. Example Usage An example of using the filter to […]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"codex-type":[27],"class_list":["post-541","codex","type-codex","status-publish","format-standard","hentry","codex-type-filters"],"_links":{"self":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/541"}],"collection":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex"}],"about":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/types\/codex"}],"author":[{"embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/comments?post=541"}],"version-history":[{"count":7,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/541\/revisions"}],"predecessor-version":[{"id":1932,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/541\/revisions\/1932"}],"wp:attachment":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/media?parent=541"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/tags?post=541"},{"taxonomy":"codex-type","embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex-type?post=541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}