Attachment search not working correctly

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Attachment search not working correctly

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25549
    Devonchurch85
    Devonchurch85
    Participant

    Hi there.

    I’m developing a website for my client. I have run into a problem with ASP and searching attachments.

    First of all, the email address for the account is my clients so I will only see support request updates through your website unless you can let me know at [email protected]

    The search works perfectly but when clicking on a search result for an attachment the “attachment parent post” will not be displayed. Only the attachment JPG is displayed. I have of course set up the plugin to return attachments in the parent post.

    Search form “Website search”

    So, here’s an example:

    https://dcl.reeskenyondesign.co.uk/website-search/
    Search for “Braunton Church Medieval”

    Result: at the bottom of the search results you will two pictures of churches which are attachments with the search term. Clicking on either of these results in:

    https://dcl.reeskenyondesign.co.uk/wp-content/uploads/2020/01/Braunton-Church-Medieval.jpg
    or
    https://dcl.reeskenyondesign.co.uk/wp-content/uploads/2020/01/Braunton-Church-Medieval-Tower-Spire.jpg

    What should be returned is this:
    https://dcl.reeskenyondesign.co.uk/churches/overview-braunton-church-of-st-brannock/
    or
    https://dcl.reeskenyondesign.co.uk/churches/basics-braunton-church-of-st-brannock/

    it’s critical that this works because this is one of the main reasons why we purchased the plugin.

    Can you take a look please and let me know what the solution is.

    In advance, thank you.
    Rees Kenyon – web dev and designer

    #25561
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Rees,

    Thank you for all the details, it helps us a lot.

    Okay, so I checked the given posts and their attachments, and I see the problem. The given images are not actually attached to that post, but only used in their contents. You can check that this way:
    – Open the post editor and click “Add Media”: https://i.imgur.com/MKESsrz.png
    – Click the Media library: https://i.imgur.com/GgjOGvj.png
    – Change “Uploaded to this”: https://i.imgur.com/ZkMVhlx.png
    As you can see, there is only one image attached to the post, when searching that image name, the post is returned as it should.

    When the plugin indexes the attachments, it checks the database for the attachment parents, but in this case their parents are not defined in the database, because they are not attached to any post, but simply uploaded as images (or the parent was deleted).
    Unfortunately currently there is no way of getting in which post was the attachment image used, as the post contents does not contain a connection between the image object, only the image URL.

    I am not sure if there is a way to natively change the attachment parent IDs via editor, but there might be plugins out there for this purpose.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #25563
    Devonchurch85
    Devonchurch85
    Participant

    Hi Ernest.

    Thank you for taking the time to explain why the attachments aren’t recognised in the page or post.

    I have found a workaround which might be really useful for you to use as a future suggestion for others.

    I’m using themify builder and like many other visual composition software it breaks out of the usual WordPress publishing methodology.

    My trick is to add a text box (builder component) at the bottom of the post and add all the media attachments used in the this post. I then add a <noscript> at the beginning of these attachments and a </noscript> at the end in the tinymce text view option. This in turn attaches all the images to the post but of course doesn’t display or load them so they have no effect on page load, the DOM, page rendering and probably more importantly load balancing.

    You can see how I did this here if you want to take a look:
    https://dcl.reeskenyondesign.co.uk/wp-admin/post.php?post=544&action=edit&classic-editor

    Thanks,
    Rees.

    #25564
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Rees,

    Wow, that actually works. What an interesting solution, thanks for sharing. I will take a note of this for sure.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.