Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › VTT Files in Attachment Search
- This topic has 9 replies, 2 voices, and was last updated 2 years, 4 months ago by
Ernest Marcinko.
-
AuthorPosts
-
January 11, 2024 at 4:58 pm #46569
john759
ParticipantHi I was wondering if it’s possible to include .vtt files in the Media Libray of WordPress in the Search Results? I see that txt files will work but I have a lot of .vtt files that I would like to use if possible. I included the text and manually entered this in the File Indexing Options but the vtt files did not get parsed by the Media Service.
Thanks!
John
January 11, 2024 at 5:47 pm #46571Ernest Marcinko
KeymasterHi 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.
January 11, 2024 at 6:56 pm #46577john759
ParticipantThanks a lot. I put the function in and re built the index but still doesn’t seem to add them. I’m checking this by looking at the attachment content which is saying for txt files – Parsed content by Ajax Search Pro Media Parser service
Looking at vtt files that content is not showing up as parsed.
January 12, 2024 at 9:46 am #46583Ernest Marcinko
KeymasterI just tested but it seemed to work okay on my end.
If you haven’t, then can you please try to add text/vtt to the index list and create new index?
If no luck, then can you add temporary back-end and SFTP access? I will try do debug manually.January 12, 2024 at 12:38 pm #46588john759
ParticipantOk looks like it did work. When vtt files are parsed then the Content will not show on the Media Attachment page like it does for the txt files. Looks like the content of the VTT file can be searched and those posts where vtt files are attached will find the keywords but the search results terms will not show up. No excerpts seem to be found for the vtt files.
Do you think that vtt file content is unable to show up in the results? if so then I can just txt files.
January 13, 2024 at 7:06 pm #46593Ernest Marcinko
KeymasterOh, the file may be parsed very well, the code just does not include that part, try this:
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' ) { $content = file_get_contents(get_attached_file( $post->ID )); update_post_meta($post->ID, '_asp_attachment_text', $content); return $content; } return ''; }If all goes well, then after indexing it should show the file contents.
January 14, 2024 at 2:57 am #46594john759
ParticipantOk that worked great! Thanks so much
January 14, 2024 at 10:30 am #46595Ernest Marcinko
KeymasterGreat 🙂
I have also made a feature request which I already resolved, so from the upcoming release the text/vtt type is going to be supported by default.
If you don’t mind, I will close this topic soon and mark it as resolved, feel free to open another one if you have other questions or issues.
If you like the plugin and have not rated already, feel free to leave a rating on your codecanyon downloads page and on the wordpress plugin repository, it’s greatly appreciated.
January 14, 2024 at 1:36 pm #46596john759
ParticipantOk sounds good! The plugin is the best I’ve seen for WordPress. Works incredibly well.
January 14, 2024 at 1:45 pm #46599Ernest Marcinko
KeymasterThank you very much 🙂
-
AuthorPosts
- The topic ‘VTT Files in Attachment Search’ is closed to new replies.