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

VTT Files in Attachment Search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support VTT Files in Attachment Search

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #46569
    john759john759
    Participant

    Hi 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

    #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.

    #46577
    john759john759
    Participant

    Thanks 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.

    #46583
    Ernest MarcinkoErnest Marcinko
    Keymaster

    I 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.

    #46588
    john759john759
    Participant

    Ok 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.

    #46593
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Oh, 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.

    #46594
    john759john759
    Participant

    Ok that worked great! Thanks so much

    #46595
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Great 🙂

    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.

    #46596
    john759john759
    Participant

    Ok sounds good! The plugin is the best I’ve seen for WordPress. Works incredibly well.

    #46599
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Thank you very much 🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘VTT Files in Attachment Search’ is closed to new replies.