{"id":2748,"date":"2022-04-21T18:03:23","date_gmt":"2022-04-21T12:33:23","guid":{"rendered":"https:\/\/imageattributespro.com\/?p=2748"},"modified":"2023-04-25T00:36:19","modified_gmt":"2023-04-24T19:06:19","slug":"use-exif-data-as-image-attributes","status":"publish","type":"post","link":"https:\/\/imageattributespro.com\/use-exif-data-as-image-attributes\/","title":{"rendered":"Use EXIF Data As Image Attributes"},"content":{"rendered":"\n

In this doc we will look at creating a custom attribute tag<\/a> for Image Attributes Pro that reads the EXIF data from each image. <\/p>\n\n\n\n

You can use the bulk updater and update image title, alt text, caption or description with EXIF data from your images. <\/p>\n\n\n\n

To create the custom attribute tag %exif_data%<\/code> add the following code to the functions.php<\/code> of your active theme.<\/p>\n\n\n\n

\/**\n * Custom tag %exif_data% for Image Attributes Pro.\n * \n * @param $image_id (integer) The ID of the image that is being updated. \n * @param $parent_post_id (integer) The post to which the image is uploaded to. \n * @param $args (array) An array containing additional arguments.\n * \n * @return string EXIF data or empty string if no data is found.\n * \n * @refer https:\/\/imageattributespro.com\/codex\/iaffpro_get_custom_attribute_tag_tagname\/\n *\/\nfunction iaffpro_get_custom_attribute_tag_exif_data( $image_id, $parent_post_id, $args = array() ) {\n\n\t$image_url = wp_get_attachment_url( $image_id );\n\t$exif_data = @exif_read_data( $image_url );\n\n\tif ( $exif_data === false ) {\n\t\treturn '';\n\t}\n\n\t\/**\n\t * Refer to this example EXIF data for more EXIF data sources:\n\t * https:\/\/gist.github.com\/arunbasillal\/7969b387ef970f4c99b4fdcbc77f7842\n\t *\/\n\tif ( isset( $exif_data['Make'] ) ) {\n\t\treturn $exif_data['Make'];\n\t}\n\n\treturn '';\n}<\/code><\/pre>\n\n\n\n

Now you will be able to use %exif_data%<\/code> as custom attribute tag in Image Attributes Pro settings. <\/p>\n\n\n\n

\"Custom<\/figure>\n\n\n\n

Things To Note<\/h2>\n\n\n\n