This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: VTT Files in Attachment Search

#46571
Ernest MarcinkoErnest Marcinko
Keymaster

Hi John,

I had to take a look at the source code for this, the mime type is indeed not registered between the allowed ones.

However, there is still a way to get it working, as VTT files are simple subtitle txt files:

add_filter('asp_index_file_custom_parse', 'asp_index_file_custom_parse_vtt', 10, 2);
function asp_index_file_custom_parse_vtt($text, $post) {
	if ( $post->post_mime_type == 'text/vtt' ) {
		return file_get_contents(get_attached_file( $post->ID ));
	}
	return '';
}

Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

After adding this code, create a new index and the VTT file contents should be indexed as well.