Support » Plugin: Ajax Search Lite » Ajaxsearchlite: only CSS shows up for image gallery search results

  • Resolved dogdays

    (@dogdays)


    It’s great that the shortcodes are stripped out in this version (still see the video codes though), but now what can I do to remove the css from the search results that are showing up in image/product galleries (uses WP’s built-in “create a gallery” interface)?

    I was thinking it would be an option to just not include those pages in the search results… but then what’s the point, if its an eCommerce website that has numerous product galleries?

    I mean, all of the products in the individual galleries have captions… why aren’t those showing up instead of the CSS?

    Also, the image galleries don’t show thumbnails, which is weird too because: they are image galleries.

    See a screenshot here: // http://oi57.tinypic.com/2004r5v.jpg //

    Please suggest a solution, if you can. Sorry, but I may have to move on to another search plugin and change my WP review if there’s no solution for this.

    https://wordpress.org/plugins/ajax-search-lite/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi!

    The reason why there are no images it’s because the image galleries are shortcodes themselves, and a raw shortcode does not contain information about images, thus the search cannot see them.
    The solution would be to filter this content before parsing the images, but this might slow down the search too much. I’m not even sure that the built in shortcodes are possible to “run” on a delayed filter call.

    Anyways, here is what you should do:
    Open up the plugins/ajax-search-lite/includes/search_content.class.php file and go to line 372, where you should see this:

    $im = wpdreams_get_image_from_content($post->content, 1);

    change that line to:

    $im = wpdreams_get_image_from_content(apply_filters('the_content', $post->content), 1);

    I’m not sure if this will work, but there is no other solution. It’s not the search’s falut tough, it’s just not possible.
    If you start to see images on posts with galleries, then it works 🙂

    As for the css issue. The shortcodes are not removed by default, so I guess the css comes from the gallery shortcode itself.
    The search treats everything as text. I mean there is no difference for a program between CSS code and actual meaningful content. The problem is, that the filtered gallery shortcode contains the styles and the scripts first, then the tags and other stuff.

    There are two options here:
    1. Stripping the shortcode from the search content
    2. Stripping the style and script tags from the search content

    (1.) How to:

    Open up the wp-content/plugins/ajax-search-lite/includes/search_content.class.php file and go to line 326, you should see this:

    if ($_content != "") $_content = apply_filters('the_content', $_content);

    Now, change that line to:

    if ($_content != "") $_content = strip_shortcodes($_content);

    (2.) How to:

    Open up the wp-content/plugins/ajax-search-lite/includes/search_content.class.php file and go to line 326, you should see this:

    if ($_content != "") $_content = apply_filters('the_content', $_content);

    Add these lines after that line:

    if ($_content != "") $_content = preg_replace('/<style[^>]*>([\s\S]*?)<\/style[^>]*>/', '', $_content);
    if ($_content != "") $_content = preg_replace('/<script[^>]*>([\s\S]*?)<\/script[^>]*>/', '', $_content);

    I hope this helps.

    Excellent. Those worked. I’ve got images and no codes. You rock. Thank you so much!

    Just one last thing… but I’ll start a new topic: Excluded page ID’s not returning after they’re removed from List.

    Forgot… resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Ajaxsearchlite: only CSS shows up for image gallery search results’ is closed to new replies.