Get WPFTS Pro today with 25% discount!

[Solved] Media Library Folders Pro indexing issue


  • Recently we found an issue with Media Library Folders Pro plugin. Our client is using it to upload new files to the WP Media Library using the folder structure. But the problem was after the new file is successfully uploaded, it does not get indexed automatically by the WPFTS Pro.

    After some investigation, we detected that reason was that Media Library Folders Pro plugin does not encode file paths properly on Windows OS servers.

    For example, if you're uploading the file "file.pdf" into the subfolder "2020/12" of the standard WP uploads folder, the path normally should be

    c:\www\domain.com\wp-content/uploads\2020/12/file.pdf

    Later, the WP Core function parses this path and cuts out the highlighted part, because it is EXACTLY equal to WP's "upload_dir" value.

    But because of the Media Library Folders Pro bug, the file path becomes different:

    c:\www\domain.com\wp-content\uploads\2020\12\file.pdf

    Because of this, the WP Core function can not cut out the upload_dir part, and also it removes backslashes, so the final result becomes very strange and not acceptable by WPFTS Pro in any case:

    c:wwwdomain.comwp-contentuploads202012file.pdf

    To fix this, we have to create the custom code for the _wp_relative_upload_path filter. So the result looks like this:

    add_filter('_wp_relative_upload_path', function($new_path, $path)
    {
    	// This code will only work in case Media Library Folders is installed and active
    	if (class_exists('MaxGalleriaMediaLib')) {
    		// We going to replace '\' to '/' before comparison
    		// to make this code compatible with Windows-style paths
    		$new_path = str_replace("\\", "/", $path);
    
    		$uploads = wp_get_upload_dir();
    		$up_dir = str_replace("\\", "/", $uploads['basedir']);
    		if ( 0 === strpos( $new_path, $up_dir ) ) {
    				$new_path = str_replace( $up_dir, '', $new_path );
    				$new_path = ltrim( $new_path, '/' );
    		}
    	}
    
    	return $new_path;
    }, 30, 2);
    

    If you need the ready solution only, just download, install, and activate this:
    wpfts-addon-media-library-folders-1.0.0.zip

Suggested Topics

  • 0 Votes
    5 Posts
    1k Views
    G
    @EpsilonAdmin Thanks for quick response and question. Yes, my hope was to use the standard WP search widget - but I haven't explored any other option. If there's a better way I'm happy to get guidance My site has been recently re-created in WordPress after quite a few years of running under Joomla and that Joomla installation had a free plugin called jiFiles (?) which did the document scanning/indexing. A standard search, scoped on file name or a string from within file content, would pull up a list of file names each hyperlinked to the file itself to easily click on for in-browser viewing (or possibly downloading). I appreciate that there are other WordPress plugins that offer a full document management system but they have a much larger feature set than I need and are also majorly expensive for a small non-profit community web site.
  • 0 Votes
    1 Posts
    947 Views
    No one has replied
  • 0 Votes
    3 Posts
    1k Views
    EpsilonAdminE
    Yes, you can do that. But it will need some coding. First of all, we need to extract a PDF link or file path from the post. It should be done at indexing stage, inside the 'wpfts_index_post' hook function. After the link/path extraction, we should read this file and extract the text information from it. It still should be done inside the same hook. Okay, when we have the text, we put it to one of the index clusters (your preference) and let it to the indexer to make its job as well. The final code will depend from the way how you have attached the PDF file to the parent post. It can be done using very different ways. Please give me some more explanation of this and I will post the semi-ready code here.
  • 0 Votes
    2 Posts
    2k Views
    EpsilonAdminE
    There is a simpler way for fix the Avada Theme search results issue in case you're using Avada Theme 7.0+. In this version the authors enabled to override the output of search results by the hook. So using the simple addon become possible. Just download it and install. And enjoy the Smart Excerpts wpfts-addon-avada-theme.zip
  • 0 Votes
    3 Posts
    1k Views
    EpsilonAdminE
    @mlg4035 Thank you very much!

Be the first to read the news!

We are always improving our products, adding new functions and fixes. Subscribe now to be the first to get the updates and stay informed about our sales! We are not spammy. Seriously.

Join Us Now!

We are a professional IT-team. Many of us have been working in a Web IT field for more than 10 years. Our advanced experience of software development has been employed in the creation of the WordPress FullText Search plugin. All solutions implemented into the plugin have been used for 5 or more years in over 60 different web-projects.

We are looking forward to your comments, requests and suggestions in relation to the current plugin and future updates.

ewm-logo-450

The forum powered by NodeBB | Contributors