{"id":1928,"date":"2021-06-18T01:08:22","date_gmt":"2021-06-17T19:38:22","guid":{"rendered":"https:\/\/imageattributespro.com\/?post_type=codex&p=1928"},"modified":"2022-03-22T10:28:04","modified_gmt":"2022-03-22T04:58:04","slug":"iaffpro_html_image_markup_post_update","status":"publish","type":"codex","link":"https:\/\/imageattributespro.com\/codex\/iaffpro_html_image_markup_post_update\/","title":{"rendered":"iaffpro_html_image_markup_post_update"},"content":{"rendered":"\n

Modify the image HTML markup after the bulk updater has added the necessary attributes. <\/p>\n\n\n\n

\/**\n * Filter the image HTML markup. \n * \n * Useful to add custom image attributes or remove existing attributes.\n * Example: You can add Lazyload attributes or Pinterest attributes) on all images. \n * \n * @param $match[0] (string) The image HTML markup (<img alt=\"\" title=\"\" ...) without \n * the closing '>' after it is updated by Image Attributes Pro.\n * \n * @since 1.4\n *\/\nreturn apply_filters( 'iaffpro_html_image_markup_post_update', $match[0] );<\/code><\/pre>\n\n\n\n

$match[0]<\/code> contains the image markup without the closing ‘>’ tag. <\/p>\n\n\n\n

For example:<\/strong><\/p>\n\n\n\n

<img title=\"Image Title\" src=\"https:\/\/imageattributespro.com\/wp-content\/uploads\/2021\/05\/custom-filter-and-regex-filter-image-attributes-pro-result.png\" alt=\"Image Alt text\" class=\"wp-image-99\"\/<\/code><\/pre>\n\n\n\n

Note<\/strong>: This filter is triggered only when the bulk updater updates the images within the post or product HTML. Be sure to select the appropriate Bulk Updater Behaviour<\/code> in the Bulk Updater Settings<\/code> tab. <\/p>\n\n\n\n

\"Select<\/figure>\n\n\n\n

Example Usage<\/h2>\n\n\n\n

An example of using the filter to add a custom data-origin=\"Your Name\"<\/code> to each image. Add this to the functions.php<\/code> of the active theme.<\/p>\n\n\n\n

\/**\n * Add custom data-origin attribute to every image. \n * \n * @param $match (string) The image HTML markup after the bulk updater \n * has added the necessary attributes.\n * \n * @author Arun Basil Lal\n * @link https:\/\/imageattributespro.com\/codex\/iaffpro_html_image_markup_post_update\/\n *\/\nfunction prefix_iap_add_data_origin_to_images( $match ) {\n\t\n\t\/\/ Replace '<img' with '<img data-origin=\"Your Name\"'\n\t$match = str_replace( '<img', '<img data-origin=\"Your Name\"', $match );\n\t\n\treturn $match;\n}\nadd_filter( 'iaffpro_html_image_markup_post_update', 'prefix_iap_add_data_origin_to_images' );<\/code><\/pre>\n\n\n\n

Another example: Add Missing Image Dimensions<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

Modify the image HTML markup after the bulk updater has added the necessary attributes. $match[0] contains the image markup without the closing ‘>’ tag. For example: Note: This filter is triggered only when the bulk updater updates the images within the post or product HTML. Be sure to select the appropriate Bulk Updater Behaviour in […]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":[],"tags":[],"codex-type":[27],"_links":{"self":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/1928"}],"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=1928"}],"version-history":[{"count":8,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/1928\/revisions"}],"predecessor-version":[{"id":2292,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex\/1928\/revisions\/2292"}],"wp:attachment":[{"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/media?parent=1928"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/tags?post=1928"},{"taxonomy":"codex-type","embeddable":true,"href":"https:\/\/imageattributespro.com\/wp-json\/wp\/v2\/codex-type?post=1928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}