Indexing image metadata with Ajax Search Pro
Last updated 5 months ago
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.
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);