# Searching Image EXIF metadata

### Prerequesites

* [File Content Search ](https://documentation.ajaxsearchpro.com/general-settings/search-in-attachment-contents-pdf-word-excel-etc..)Enabled

The snippet below will hook into the index process and read the file EXIF metadata to append to the indexed image files. It works for all image mime types.

[What is this, and where do I put this custom code?](https://knowledgebase.ajaxsearchpro.com/safe-coding-guideline)

```php
add_filter( 'asp_index_file_custom_parse', function ( $contents, $the_post ) {
	if ( wp_attachment_is_image($the_post) ) {
		$file_path = get_attached_file($the_post->ID);
		$data = wp_read_image_metadata($file_path);
		if ( is_array($data) ) {
			$data = array_filter($data, fn($s)=>!empty($s));
			$contents = implode(', ', $data);
		}
	}

	return $contents;
}, 10, 2);
```
