Search for Images

13Jan10

Many many people requested a search function for NextGEN Gallery. Although a couple of plugins like Search Unleashed crawl already the content of a gallery, the best solution would a list of images as search result. Why is this such a problem for me and not already includes years before ?

The search injection is not that problem, but it needed always a new template or a redirection to a gallery template which maybe doesn’t fit to your theme layout. I never found the best way, but here is one first try. I’ve create a small addon plugin. You just need to activate it, it has no parameter or settings.

Now you must add to your theme the follow function :

<?php if ( function_exists( 'ngg_images_results' ) ) ngg_images_results(); ?>

This little code return the image search result for the standard search widget from WordPress. Example here : http://nextgen-gallery.com/?s=cologne

UPDATE : I’ve a added the search for tags , there are still the issue with the pagination… but Im working on it.
Should be fixed now with Version 0.7.0, you need as well this update until NGG V1.8.0 is released

You can download the code and a modified search.php for the default theme here :

Download NextGEN Search Engine 0.7.0
Test version @ Google Code

111 Responses to “Search for Images”


  1. Gravatar Icon 1 Bjorn Posted January 14th, 2010 - 01:30

    Great work Alex! I just tried it and it works perfect :)

  2. Gravatar Icon 2 Bjorn Posted January 14th, 2010 - 01:49

    after some extra tests i found out that when a search result has the same name as one of your pages, the navigation no longer works.

    In stead of going to page 2 of the search results, it triest to go to page 2 of the page with the same name as the search result.

    Example:
    Search result – http://www.gasjeerbij.nl/?s=leon+smits&button=
    But when trying to enter page 2, it links to http://www.gasjeerbij.nl/specials/leon-smits/?nggpage=2

  3. Gravatar Icon 3 Katn Posted January 14th, 2010 - 04:20

    Love it! Thank you so much! The result is clean and professional looking, just what I needed :) I think it’s making a thumbnail for file names though. Just a gray thumb with the file name on it. Is there a way I can get it to just search the tags? Not a big deal. Thank you sooooo much again!!

  4. Gravatar Icon 4 kaliningradetz Posted January 14th, 2010 - 12:29

    I agree to Bjorn. NGG navigation is using a wrong link base:

    http://kkaliningrad.ru/?s=газон

    But anyway that is great feature!

  5. Gravatar Icon 5 alex.rabe Posted January 14th, 2010 - 21:59

    Yes I know… It’s just a first try, there is always enough room for a better solution

  6. Gravatar Icon 6 Bjorn Posted January 15th, 2010 - 03:51

    Is it for now possible to get all results on 1 page?
    Would be a nice solution for me until pagination is fixed :)

  7. Gravatar Icon 7 Valerie Posted January 20th, 2010 - 05:10

    Really great job Alex! It was needed!!!

    Thank you!

  8. Gravatar Icon 8 Reinier Posted January 21st, 2010 - 22:04

    I’m so glad you took the trouble of writing this plug-in.

    I’m a newbee and have been searching the WWW for this function, not believing that someone had not come up with a solution for finding your photo’s by their name / description. And YES ! someone did!

    Works lovely apart from the pagination / navigation. It wont be long ’till this is tackled, I hope.

    Many thanks so far

    Reinier

  9. Gravatar Icon 9 Reinier Posted January 22nd, 2010 - 08:59

    @ Bjorn:

    a workaround for the navigation issue would be tot switch off pagination.
    In admin-bar Gallery –> options –> gallery –> Number of images per page: <>

    Alle pictures will come on one page. No navigation available now.

    Reinier

  10. Gravatar Icon 10 Eduardo Posted January 25th, 2010 - 11:52

    Hi, thanks for the help.
    Sorry but I am a complete ignorante about PHP. When you said to put some code to our theme, where exactly should we do it, in which file?
    And at the downloaded folder, there are two search files: where to put then? I use Chic Theme… Any help, please? Thank you.

  11. Gravatar Icon 11 Matthias Posted January 28th, 2010 - 10:07

    how do i activate the plugin?

    i do not get any possibility in my admin area!

    so where or how to activate?

    thank you!

  12. Gravatar Icon 12 Reinier Posted February 1st, 2010 - 19:17

    @ matthias:

    (though I’m realy not the expert here)

    first you must have installed the plugin “NextGEN Gallery” and have activated it.
    Then you copy the php-script as mentioned (see top of post) by Alex Rabe:

    . . . . and paste it into your theme’s search.php (or search_result.php or something like that, depending on the theme you are using).

    You can edit the search.php from your admin-bar, choose appearence –> edit –> look up the search.php in your right hand-side sidebar.

    left-click will open the php.file.

    For me, the best place to insert the script was right above the part that says:

    After insertion save the php-file and you’re ready to roll.

  13. Gravatar Icon 13 Valerie Posted February 2nd, 2010 - 15:29

    This is strange…
    Is it supposed to search in gallery tags? Because it does not for me… So what are the Nextgen tags for exactly?

    But when I search a specific tag it gives me 1 result while it should give me 2, and no result for all the other tags…

    Help please!

  14. Gravatar Icon 14 Valerie Posted February 2nd, 2010 - 16:28

    OK, the 2nd paragraph of my previous message is not true anymore this morning…. None of the tags seem to be searched?

    Anyone can tell me how Nextgen tags can be used?

    thank you!

  15. Gravatar Icon 15 Ulrik Posted February 2nd, 2010 - 19:30

    Great, thanks Alex…!

  16. Gravatar Icon 16 alex.rabe Posted February 2nd, 2010 - 21:57

    I’ve updated now the plugin, it search as well for tags

  17. Gravatar Icon 17 Valerie Posted February 2nd, 2010 - 23:19

    Wow you are great! Thank you so much alex!!! :)

  18. Gravatar Icon 18 Valerie Posted February 2nd, 2010 - 23:40

    Oh alex! A last question. Would it be simple to put a link on a page showing the results of a search?

    If for example I have mny types of dresses in my gallery, could I have a link on a page saying “blue” and then when we click on it it shows all the results of the search for blue?

    TY!

  19. Gravatar Icon 19 hartlijn Posted February 3rd, 2010 - 12:23

    quite nice this plugin!
    works like a charm.

    One question: how can I avoid one picture to be shown twice, because the search entry word is found in tag and title or description?

    I see you built a duplicate-result check or how to call it: if the search entry is found in both the title and the description, you only show that picture once. Very good.

    But when the search entry is found in the title or description AND as tag for one picture, the picture is shown twice.

    How can I avoid that?

  20. Gravatar Icon 20 NeilP Posted February 3rd, 2010 - 14:55

    Being new to both WP and PHP I’m really very impressed with NextGen gallery and associated plugins. Until a few weeks ago I was using static html.
    I’d love to use this images search but I don’t know what I’m doing wrong.

    Whilst using the default WP theme I’ve replaced the default search.php file with the updated search.php provided in the download. But nothing new happens when I search (posts are returned as standard but no images).

    What do I do with the nggsearch.php file provided in the download? I’m no doubt missing something vital.

  21. Gravatar Icon 21 Valerie Posted February 4th, 2010 - 00:51

    Hello NeilP, maybe if you use tags only to add information that you do not find in the title it could do the trick…

    In my case, tags add info not provided by the title nor the description and it works very well.

  22. Gravatar Icon 22 Valerie Posted February 4th, 2010 - 00:52

    Oops sorry, my previous message was for hartlijn. :)

  23. Gravatar Icon 23 peter Posted February 4th, 2010 - 17:11

    Hi Alex,
    Great you’re working on a search function for nextgen!
    The search function you created works well in many situations. In other situations, however, it lacks the functionality i think is needed.
    Currently, not all gallery / album fields are taken into account when searching. Likely the function can be extended to cater for this.
    Another issue i have, is that i use images as illustrations on posts and pages – next to a ‘normal’ gallery. what i really need, is a link to the post(s) / page(s) where the images are used, if they meet the search criteria.

    All in all i’ll continue to use nextgen in combination with search unleashed (su) and qtranslate(qt) to cater for full, multilingual search functionality.
    Maybe the scope of such a search function is a bit too wide for this moment, but i’ll just have a go.. Possibly it makes you wanna have another go at hooking up nextgen and su again!

    Here’s what i have done (in wp2.8.4 with the latest versions of these plugins at that time) to create full, multilingual search.

    i’ve slightly hacked nextgen’s function ‘load_dependencies’ to load the proper backend libraries when su is running to do its indexing. ideally this would be an option in nextgen.
    What is still lacking is a function to kick off su re-indexing when something has changed in nextgen; currently one needs to kick off the su re-indexing manually (or run a cron job or something similar) before the changes in nextgen can be found when searching.

    there’s also a hack i have to apply to nextgen to support multiple languages; function ‘nggloader’ directly loads the nextgen language file whereas that should actually be done with an add_action to ‘init’ so that the loading of the language file is controlled by wp. without this change, nextgen doesnt properly respond to language changes.

    less relevant to nextgen but for completeness sake: lastly there’s a couple of hacks needed in su to a) index all data in stead of only the data of the active language, and b) properly index tags since their translations are stored in a qt specific internal table and not in the wp term tables.

    I’m very much interested in getting this solution properly implemented in nextgen and su and would gladly try to help you do so! so if you would consider giving it another go..?

    Kind regards,
    Peter

  24. Gravatar Icon 24 Bolser Posted February 12th, 2010 - 01:23

    in archive, in file search.php dublicated ngg_images_results function. Thanks!

  25. Gravatar Icon 25 Bolser Posted February 12th, 2010 - 01:25

    or not? My search resault are working without “elseif”

  26. Gravatar Icon 26 Laura Posted February 19th, 2010 - 12:32

    Help! I’ve downloaded the latest version of the plugin but it doesn’t appear to want to search my NextGen image tags it only searches the pages. Any suggestions?

  27. Gravatar Icon 27 Laura Posted February 19th, 2010 - 14:09

    Oops – got this sorted now! Wonderful plugin – thanks!

  28. Gravatar Icon 28 daniellench Posted March 4th, 2010 - 04:54

    can someone confirm if google can search these tags and or descriptions?

    either by default or with the search plugin.

    i am moving this site: http://ssattic.com from a drupal and gallery2 setup to wordpress and nextgen. the gallery2 has a “keywords” section for images that is searchable and does appear in google et al

    any info would be helpful, thanks for a super plugin. as far as i’m concerned it is the only gallery for wordpress.

    best,
    dan

  29. Gravatar Icon 29 Matt Posted March 4th, 2010 - 21:14

    I must be clueless. I uploaded the .zip folder, activated it, and dropped…

    …into search.php and functions.php (not at the same time) and I’m still not getting any results, as well as having two search fields.

    What am I missing here?

  30. Gravatar Icon 30 Jon Posted March 19th, 2010 - 08:38

    I’m confused about what this add-on plug-in is actually supposed to do? Was this already added into NGG 1.5 and that’s why I’m not seeing any new search functionality? or is there more to enabling it than dropping it in the plug-in directory and activating it?

    Regardless, all I was looking for was the ability to search through the NGG images in the “Add Image” dialog box accessed from the edit post window like can be done for images in the WP Media Library. NGG has the ability to search within the Gallery / Manage Gallery page, but not from the insert/add image box.

    Finally THANK YOU for adding WP thumbnail support to that dialog.

    In truth I don’t think I need most of the functions of NGG, I just want #1 some way to group my 400 stock images into categories and #2 any easy way to find (search and categories) them and attach them to posts in the future.

  31. Gravatar Icon 31 Kasper Posted March 22nd, 2010 - 12:57

    Hi!
    Great plugin. It works perfect when I use an effect like thickbox. But if I want to use the imagebrowser to open the images I can’t click the thumbnails when I search. Any idea how to fix this?

    You can see an example of the problem on this page:
    http://kbphoto.dk/%3C?s=oman&submit&pid=33

  32. Gravatar Icon 32 Foto Andy Posted April 21st, 2010 - 17:15

    Thank you Alex for sorting out this otherwise baffling challenge.

    (Tried some of the WP support-generated hacks, they all broke my admin except yours.)

    You continue to earn my donation renewals…

  33. Gravatar Icon 33 Janet Taylor Posted May 11th, 2010 - 18:40

    Wow, Alex. This is so close to being awesome. If you have time to sort out the pagination and the duplicate results, that would be amazing. Right now, I’ve deleted a bit of nggsearch.php, so that it only searches on tags, which gets rid of the duplicates, but it would be great to get the merging/filtering fully working.

  34. Gravatar Icon 34 RRG Posted May 18th, 2010 - 23:00

    Hey Alex, maybe in the future you can make a note for us none php experts that what we actually need to do. All of the above is a bit on the confusing side. I think saying, “paste this into your search.php file in place of what is there” would be much better than just “You can download the code and a modified search.php for the default theme here :” I’d guess that many will download and simply upload like a plug in.

    No matter, it is pretty awesome and I thank you. So far it works, but not well. Its listing them in a very small column. I have no idea how to change how this will list out, but if I know you, I have to scour the code to find out.

    My question is…What do we do with the “nggSearch.php” ?? Again, Have no idea as there are no directions for this stuff.

    Thanks for reading
    RRG

  35. Gravatar Icon 35 RRG Posted May 19th, 2010 - 00:11

    Sorted it out after trying to just install it as a plug in, Who knew?

    As well, i’m sure everyone is having the same problem, but you have to adjust your CSS to match what is refereed to in the template by Alex. Changes are there is not entry for what Alex called:
    div id=”content” class=”narrowcolumn” role=”main” I made my own css entry and gave them new names so it would renter the columns correctly, rather than overlapping.

    But I do have a real question here..

    With out going into too much detail; how to you tell this wonderful search option to only search for tags, and not the title, description and file name too? I’m sure I’m not the only one who spans multiple images into multiple gallery’s. This is especially true when you use Nextgen with a shopping cart tool to display products.

    Thanks for reading, if you have an idea please leave a note!
    RRG

  36. Gravatar Icon 36 RRG Posted May 19th, 2010 - 17:26

    Thanks to Janet Taylor, the answer to my above question about tags only search is this:

    $this->search_result = array_merge( (array) $nggdb->search_for_images( $wp->query_vars['s'] ), (array) nggTags::find_images_for_tags( $wp->query_vars['s'] , ‘ASC’ ));

    remove
    (array) $nggdb->search_for_images( $wp->query_vars['s'] ),

    so that the final line reads:
    $this->search_result = array_merge( (array) nggTags::find_images_for_tags( $wp->query_vars['s'] , ‘ASC’ ));

    I hope this can help, thanks again Janet!
    RRG

  37. Gravatar Icon 37 RRG Posted May 19th, 2010 - 18:42

    Hello, I do have a question.

    This search options works great. You can make it search for tags, you do a search, the images in the gallery populate presto! But the question is, how to you make them populate with their description? The alt tag works, why not the description?

    I’ve been poking around and think it must be in the search.php file of the present theme. Someplace under

    I’d guess that some php code of sorts needs to tell it what to show.

    We all know I’m no good at php, has anyone sorted this question out?

    Thanks for reading
    RRG

  38. Gravatar Icon 38 CSM Posted May 23rd, 2010 - 06:18

    Hello,

    Nice addition to NGG! Thanks!

    I have a question: Does anyone know how I get this search function to search my custom fields but NOT the words in the description fields?

    I use the ngg custom fields plugin to display artist name, price, region etc but want to add at least region and artist name to the search function.

    Heres the site: http://zhoom.com.au/mason/galleries/mason-test-1/

    If you type in a painting name (eg, moonlight), it comes up just fine. But does not pick up any regions, artist names etc.

    Heres a download link to my slightly customized search.php: http://www.zhoom.com.au/mason/wp-content/themes/mason5_1000px_width/search.zip

    Any ideas?

    Thanks in advance!!

  39. Gravatar Icon 39 Meginoz Posted May 23rd, 2010 - 11:18

    Hello, this sounds exactly like what I’m looking for, but I can’t get it to work. Lots of people have asked exactly what to do with the files in the download and I don’t see an answer. (To those people who posted the same question, then posted “don’t worry I sorted it out” – please tell us HOW you sorted it out.)

    I have changed my theme temporarily to the default one so I can get it working with that and then worry about making it work in my own theme. I replaced the default theme’s search.php file with the one from the download.

    I wasn’t sure what to do with the nggsearch.php file – I put it in the nextgen-gallery folder. Where is it meant to go?

    The search still seems to be just searching blog posts, not image tags, as it doesn’t find anything.

    Can we please have a step by step of what exactly to do with the files?

  40. Gravatar Icon 40 CSM Posted May 23rd, 2010 - 14:33

    Meginoz…I figured it out by good luck rather than by good management!

    I’m no expert so prob can’t give specific advice but here’s how to get the plugin working.

    Go to your dashboard–>plugins–>add new–>upload–>choose file (the zip file)–>install now–> then activate once it has uploaded and installed.

    Then the plugin should appear in your plugins list.

    Once the plugin works, you should just be able to replace your theme’s search.php with the one from the download. this should enable the search function but will likely screw up the whole look of your search page because, as RRG said above, you need to customize the [New] search.php that comes with the plugin to suit your own theme. I.e, you will need to match up the css and div tags to match your theme’s search.php

    What I did was actually take the [NGG] search.php and copy and paste the important code into my theme’s search.php.

    The code I copied starts with the following, and is from line 37 to line 56 (in my editor):

    And I inserted it into my theme’s search.php within the div tags i wanted. I am still yet to finish tidying up the css but you get the idea…

    As you can see I did not copy the code before line 37 because I only want my search to find images, not related posts, pages etc.

    If you want your search results to show general posts and pages etc and then list images you will need to amend the whole file to suit your theme.

    I hope this helps a little! If you want some more info I’ll try to help as much as I can!

    You can see my search working (almost the way I want it) here: http://zhoom.com.au/mason/?s=moonlight&search=Search

    If anyone knows how to get the search to find the custom fields please tell me!!

  41. Gravatar Icon 41 CSM Posted May 23rd, 2010 - 14:35

    Sorry here is the first few lines of the code I copied…line 37-56

    Image Search Results

  42. Gravatar Icon 42 Meginoz Posted May 23rd, 2010 - 15:24

    CSM, thank you. The code snippets in your post seem to have been stripped out, but I get the general idea.

    It didn’t occur to me to install it by uploading the zip file, as I never install plugins that way, I just FTP the plugin folder up – but as this one didn’t have a folder with the plugin name inside the zip file, I thought you just had to copy those couple of files in somewhere.

    So, looks like basically the steps to get it working are:
    - Install it by uploading the actual zip file through the Add New section on the plugins page
    - Activate it
    - Put the search.php file into your theme

    (Then you have to tidy up the CSS etc, but the above two steps make the basic functionality work.)

    I now have it kind of working, but it is duplicating a lot of the images. I think that might be the problem that RRG posted above, so I will need to have a look at that later.

    Thanks for your help.

  43. Gravatar Icon 43 Michael Posted May 23rd, 2010 - 19:45

    I recently installed this to my gallery and find it has the oddest results. The result of a search gives the relevant images but the images don’t link to their pages…. or, rather, they do but the page is always some random text page or blog post. For example:

    The search
    http://tenthousandvisions.com/?s=mind
    results in four images.However, they all show the content of the page “Events” when clicked on even tho their URL is the correct picture/gallery page.

    This happens with all images searched. They always show seemingly random content from somewhere else. Can anyone tell me why this might be?

  44. Gravatar Icon 44 CSM Posted May 24th, 2010 - 01:32

    yeah, sorry…seems the code didn’t want to paste properly…

    I think part of the duplicate results problem is that the search function searches all description, tags and titles. It seems RRG has posted a solution above whereby you set the search engine to just search image tags. maybe that will help?

    Michael could it be to do with your permalinks? Did you activate permalinks in the NGG options? If so, try updating them once and see if that makes any difference…Great artwork too!

  45. Gravatar Icon 45 Michael Posted May 24th, 2010 - 02:53

    CSM – after clearing the cache and updating (unchecking/save/check/save) the permalinks nothing changed…. It’s very odd behavior but it seems that no one else has this problem.

  46. Gravatar Icon 46 CSM Posted May 24th, 2010 - 06:50

    I believe to properly update your permalinks you need to go to dashboard–>settings–>permalinks–>then click save changes…you should then get a little yellow box up top saying permalink structure updated.

    By the way have you backed up your blog? I would strongly suggest doing this before playing with code or anything else..I have learnt this the hard way!!

  47. Gravatar Icon 47 Michael Posted May 24th, 2010 - 12:36

    Well, yes, I did that too.

    The URL that is returned for any given image is something like:
    http://tenthousandvisions.com/nggallery/post/altar/image/188

    so that it adds this other stuff in, for whatever reason. It’s different for each search result but gives the same link with a dif. picture number for each search.

    What I really would like if for it to return a link to that particular images page as one would see it from its respective gallery. I don’t use any of the effects and rely on the image browser function.

    By the way – i did back all of this up…

  48. Gravatar Icon 48 CSM Posted May 29th, 2010 - 03:12

    mmm…Sorry Michael, I wouldn’t have any further ideas…Wish i could help further.

    I am still struggling with the search a little myself…

    If I find anything else out I’ll post it here.

    Good luck!

  49. Gravatar Icon 49 Meginoz Posted June 5th, 2010 - 13:04

    I am sooo close to having this working. I have it searching, and displaying the images only once now, and it works perfectly with the effects enabled on the gallery. BUT I just want to use the Image Browser, not the effects so it is possible to link to a single image – but when I set it up that way, I can’t get it to open up the large picture when clicking on a thumbnail in the search results.

    The page is here: http://www.myceansage.com/music-flyers
    If you click on the thumbnails in the full gallery you will see how it should work. But do a search on “art unit” and you will get four pictures, but if you click on one, it doesn’t open up the image browser.

    I’ve been looking at the gallery.php file to see if there’s something in there that I should put in my search.php file to open the image browser, but I can’t work it out at all. Any ideas?

    Thanks.

  50. Gravatar Icon 50 Meginoz Posted June 6th, 2010 - 15:01

    I’ve just read through the other comments again and noticed that a few other people have had the same problem of it not opening up the large image when using the image browser. Any chance of a fix on that Alex? I’ve been trying to figure out what bit of code controls that in the main plugin, but my PHP skills aren’t good enough.

  51. Gravatar Icon 51 Jessica Posted June 12th, 2010 - 04:16

    I as well have been searching for this for the site I’ve just finished (streetsofsanfran.com)and am so glad to find it exists. Here’s my problem. This site uses a theme called Photocrati which does not come with a search.php at all. I installed the plugin and uploaded nggSearch.php to my theme folders, but now I’m stuck. I think I will have to have a page called SEARCH but how do I get that page to pull the search function in? I tried adapting the search code from my own blog and inserting it into my test search page on this site:

    but that didn’t do anything – I had a blank page called search.

    So, can anyone tell me how to call the search function?

  52. Gravatar Icon 52 Rouven Posted June 23rd, 2010 - 04:35

    Hey Alex,

    do you have any news to the pagination issue?

    greetings from Hamburg

  53. Gravatar Icon 53 Cerafil Posted June 23rd, 2010 - 22:54

    I am using Atahualpha theme and I only have a “searchform”

    and no matter where I post this.

    it doesnt work

  54. Gravatar Icon 54 Narv Posted July 10th, 2010 - 17:31

    @Alex:
    I made a little improvement to your search-plugin by filtering out duplicate hits. Those duplicates can occure if the keywords from the search are e.g. in the title as well as in the tags.

    In nggSearch.php (located at wp-content/plugins/nggSearch-v0.6.0) I put in:
    if ( !empty($this->search_result) ) {
    $this->found_images = true;
    $temp_sort = array();
    foreach ( $this->search_result as $key => $value ) {
    if ( in_array( $value->pid, $temp_sort ) )
    unset( $this->search_result[$key] );
    else
    $temp_sort[] = $value->pid;
    }
    unset($temp_sort);
    }

    This goes instead:
    if ( !empty($this->search_result) )
    $this->found_images = true;

    Probably not the most elegante way of doing the job – but a working one.

    @Cerafil:
    In atahualpa there is an easy way to make this fly – but it took me a while to understand.

    In “wp-content/themes/atahualpa351/index.php” make sure you do NOT have a line looking like this:

    If you have it: Remove it.

    I am not sure, but it looks like it got automatically adding there by activating the search plugin – anyway – not a good place for this code.

    Instead go to the Admin-page – “Design” – “Atahualpa Theme Options” – “Style and edit CENTER COLUMN” – “Content BELOW the LOOP” – at the very end enter:

    Et voila – you get pictures – but ONLY if the keyword is also found in an article – otherwise you get “Not Found”.

    In order to fix this we need to manually edit another file:
    “wp-content/themes/atahualpa351/index.php” -

    locate the line:
    “if ( have_posts() ) : $bfa_ata['postcount'] == 0; /* Postcount needed for option “XX first posts full posts, rest excerpts” */?>”

    and replace by:
    “if ( have_posts() or ( function_exists( ‘have_images’ ) && have_images() ) ) : $bfa_ata['postcount'] == 0; /* Postcount needed for option “XX first posts full posts, rest excerpts” */ ?>”

  55. Gravatar Icon 55 Narv Posted July 10th, 2010 - 17:33

    Sorry guys – above the line to remove in Atahualpa was skipped because it contained PHP tags – look out for:
    “if ( function_exists( ‘ngg_images_results’ ) ) ngg_images_results(); ?>”

  56. Gravatar Icon 56 Narv Posted July 10th, 2010 - 17:36

    and another sorry – the block which goes at the end of “BELOW the LOOP” is this:

    “if ( is_search() && ( function_exists( ‘have_images’ ) && have_images() ) && function_exists( ‘ngg_images_results’ ) )
    ngg_images_results();”

    Make sure to remove the Hyphens and to wrap it in PHP tags.

    Alex – maybe you can clean those three comments up and put it into one – sorry.

  57. Gravatar Icon 57 Laura Posted July 27th, 2010 - 14:23

    Hi All

    Brilliant search engine! Having a slight problem on this:

    Originally when I was doing a search on the images, I was getting duplicates – i.e. if the search term was in the title or the tags then it was coming up twice.

    I managed to fix this as per the above. However when I have an image and it has two or more tags:

    eg.
    Image 1 tag1, tag2, tag3
    Image 2 tag1, tag4, tag5

    When I do a search for tag 1:
    Image 1 and Image 2 appear in my search results

    When I do a filtered search for tag 1, tag 2:
    Image 1 and Image 2 appear in my search results – I should only have Image 1 in my search results as this is the only one that contains tag1 and tag2!

    Any ideas on how to fix this?

  58. Gravatar Icon 58 Sander Poppe Posted July 28th, 2010 - 16:42

    I currently use NextGen as image library. Great plugin! Resin works well ikke. But what I try or test a search I do not get working …. Can not wait for a properly functioning search function in any Nexgten next update!

    Might result on a separate page to show that you have to create yourself with some sort of widget-like link?

    Gr, Sander

  59. Gravatar Icon 59 Terry Posted July 29th, 2010 - 20:52

    I have the gallery up and working perfectly on a large collection (8000+ images) of genealogy photos. I am having the same problem as a few others with the pagination being broken on the search results page.

    Has there been a patch or fix for this issue yet?
    It is the only thing stopping me from publishing the site.

    Thanks!

  60. Gravatar Icon 60 Jordan Posted July 29th, 2010 - 21:37

    Thank you Alex and all of you here.
    This plugin works very well on my site.
    I just have one obscure issue.
    The search on tags works for all my tags but for one tag, it doesn’t work.

    I tagged many pics with my son’s name – Adrien. All I get are the pics with his name in the filename. If I remove the filename search as described above, then I get no picture result. Searching on other tag names such as mine (Jordan) work perfectly.

    Can you tell me what’s wrong?

    Thanks,
    Jordan.

  61. Gravatar Icon 61 Alison Shuman Posted July 31st, 2010 - 06:46

    Thank you! I *almost* have this working. I run a site for a granite company and we have a TON of images. I was terribly dismayed when I realized they weren’t searchable!

    If I can figure out the kinks, I’ll post what I did. It’s be a few days!

  62. Gravatar Icon 62 Kim Posted August 10th, 2010 - 19:36

    I’ve been searching for this exact type of plugin for a long time. I have uploaded it and activated it, but I cannot get it to work.

    My theme does not have a search.php, so I added the nggsearch.php as well as renamed it to search.php and still, nothing works. There is no widget for the ngg search and there is nothing in my admin panel to edit the options.

    How do I get this to work? Any help is greatly appreciated!!
    Thank you!

  63. Gravatar Icon 63 Alison Shuman Posted August 11th, 2010 - 08:26

    Well folks, I got it working, broke it, fixed it broke it.

    Bottom line:

    1. I use a the Metro Theme from StudioPress.com and WP 3.0
    2. I downloaded and installed the plug-in.
    3. Added the single line to my search.php that Alex put in his original comments at the very top of this thread. (not posting in-line here because I don’t know how to keep the commenting software from stripping out the php)
    4. Edited the nggSearch-v0.6.0/nggSearch.php file and removed the snippets from RRG/Janet Taylor so that this ONLY searches on tags:

    (re-pasting from above):

    Thanks to Janet Taylor, the answer to my above question about tags only search is this:

    $this->search_result = array_merge( (array) $nggdb->search_for_images( $wp->query_vars['s'] ), (array) nggTags::find_images_for_tags( $wp->query_vars['s'] , ‘ASC’ ));

    remove
    (array) $nggdb->search_for_images( $wp->query_vars['s'] ),

    so that the final line reads:
    $this->search_result = array_merge( (array) nggTags::find_images_for_tags( $wp->query_vars['s'] , ‘ASC’ ));

    I hope this can help, thanks again Janet!
    RRG”

    5. Now I feel like I have some control! If I am careful about tags, my users will get what I want them to get. I can be flowery in my descriptions and not end up with a ton of “hits” for images that aren’t what I want certain search terms to show.

    YEE HAW!!!!!

    Thank you to everyone for your persistence and contributions. Y’all make the world go round!

    Alison

    (and if a 42 year old real estate agent and mother of 5 can figure this out, so can YOU!!!!)

  64. Gravatar Icon 64 Kim Posted August 11th, 2010 - 16:44

    Okay, I finally got it working.
    I downloaded the plugin, unzipped it and uploaded it via FTP.
    Then I took the search.php file located in the download (under themes->default) into my theme’s folder. That’s all I had to do to get it working properly. I made sure my tags and file name/attribute didn’t have duplicate content, so the results only show once. So, basically perfect.

    The only thing I cannot figure out is how to edit my CSS to make the search results look better. Right now they are making my right hand sidebar all out oh whack. Anyone have any ideas?

    thank you!!

  65. Gravatar Icon 65 Z Posted August 16th, 2010 - 23:11

    hi alex.
    i want to say thanks and ask if it’s possible for the search to find only the exact expression ? now it is looking in all over the pics names….

    for example…. if i give one pic the name “888″ and i have another pic with the name “138461888″ the search will show me the 2 images… i want it to find only “888″….

    maybe you can help ?

    thanks

  66. Gravatar Icon 66 Z Posted August 16th, 2010 - 23:27

    hi frieds, i have found the fix for my problem…

    in the file “nggSearch.php” on line 46 you can find the expretion:

    search_for_images( $wp->query_vars['s'] )

    just chanmge it to :
    search_for_images( $wp->query_vars )

    and that is it !

  67. Gravatar Icon 67 Terry Posted August 18th, 2010 - 22:57

    ALEX,

    Has there been any progress made on the search results pagination issue? If this issue could be fixed soon, I would be happy to make a donation for your time and my use of this plugin.

    If you have posts displayed on the same page as your image results from Search.php) it adds the link from the last item in the posts results to the page navigation links for image navigation. Hope that makes sense. I’m also hoping to work on this problem with my programmer friend tomorrow. If we can figure anything out, I will post results for everyone.

    Thanks!

  68. Gravatar Icon 68 alex.rabe Posted August 18th, 2010 - 23:02

    Sorry, Currently I work on other topics, no time to look into it…

  69. Gravatar Icon 69 Terry Posted August 18th, 2010 - 23:25

    Thanks for getting back with me Alex.

    It’s been an issue since January 2010, so I’m sure you have heard plenty of complaints. Do you have any suggestions as to what would even be causing that problem? Anywhere you can point me to look first (in the code)?

    Thanks again

  70. Gravatar Icon 70 Terry Posted August 23rd, 2010 - 21:00

    Remove beginning and ending quotation marks and wrap with php tag

    < code removed as it's getting destroyed in the comment editor >

  71. Gravatar Icon 71 Terry Posted August 23rd, 2010 - 21:01

    The Previous and Next arrow code is being converted to it’s symbol.
    You can find this in your original code. It isn’t changed.

  72. Gravatar Icon 72 alex.rabe Posted August 23rd, 2010 - 21:01

    Terry

    thanks for all the work, at the best send it to me by mail or as file at the issue tracker : http://code.google.com/p/nextgen-gallery/

  73. Gravatar Icon 73 Terry Posted August 23rd, 2010 - 21:13

    Couldn’t find your email address.

    You can download the file here: http://www.mediafire.com/?8ettfxvovod5kuv

    and I drafted the necessary changes at your google code project page.

  74. Gravatar Icon 74 Terry Posted August 26th, 2010 - 21:18

    Just found a mistake in the code I sent you.

    The navigation is fixed for search results navigation, but is broken when you try to navigate straight from a gallery page.

    I will work on it tomorrow and try to come up with a fix.

  75. Gravatar Icon 75 Posted August 31st, 2010 - 00:11

    thanxs a lot!

    exactly what I needed. Works perfect, except the noted exceptions.

  76. Gravatar Icon 76 Scott V Posted September 14th, 2010 - 18:27

    I am trying to get the search by tags feature working on the site url shown above. This site is using the gallery to display oriental rugs of different sizes. Here is an example if what a tag may look like 10′x15′, or 12’6″x15′ the returns
    The visitor can set the length and width in feet ‘ on the search

    The returns I am getting back always ignore the first setting and are only showing me the second dimension in the tag

    In this example that is 15′ is there someway for this to read both dimensions for the search and return that information.
    I think there probably is a way to do this I’m just not smart enough to know how to do it.

    Many thanks in advance to anyone that can point me in the right direction on how to do this

    Thanks
    Scott V

  77. Gravatar Icon 77 andrea Posted September 25th, 2010 - 13:27

    thanks for the plug in!!

    ùworks in wordpress 3.0?

  78. Gravatar Icon 78 Bruce Posted September 29th, 2010 - 15:08

    Hi,

    I really really want to use this code but I am not at all good with php or any of this stuff. Is there a plain language summary that can explain to me what to do and what the best code is please? I have just been through numerous other groups and some have answers to this problem and none of them work – I just don’t have the ability to troubleshoot the problems!

    I need a simple explaination – here is the code, here is where you put it!!! As if you are explaining to a child!!!

    cheers, Bruce

  79. Gravatar Icon 79 Bryan Pumper Posted September 29th, 2010 - 16:29

    Whoa! It works man! Brilliant search script / plugin that delivers! If you’re looking for a NextGen search function that works – Image search results that is, this is the one you’re looking for! Great job Alex!

  80. Gravatar Icon 80 Steve Posted November 23rd, 2010 - 03:02

    I have the image search working, but I need to limit the search to a few specific galleries. Is there a way to do this? I want to exclude some galleries from the search.

  81. Gravatar Icon 81 john Posted December 13th, 2010 - 11:08

    Hi,

    Thank you for a great add-on. I would like to combine this WP Simple Paypal Shopping cart (http://wordpress.org/extend/plugins/wordpress-simple-paypal-shopping-cart/). I got problem showing the “add to cart” button in the result page. It still in short code, eg. [ wp_cart:120:price:69:end ]; it should becomes “add to cart” button. Need help please

    Thanks before

  82. Gravatar Icon 82 Max Posted December 23rd, 2010 - 16:37

    Hello,

    thank you very much for the plugin!
    And it does search the image tags!
    I have installed k2 and it displays the image-search results in the sidebar. Do you have any ideas how i could display the results on a page?

    Best greetings
    Max

  83. Gravatar Icon 83 John Posted December 24th, 2010 - 04:43

    Hey man this is really really really AWESOME!!!!!!!
    It Works!!!!!!!!!!!!!!!!!!
    Yeah!!!!!!!!!!!
    Thanks Alot!!!!!!!!!!
    Thanks!!!!!!!!!!

  84. Gravatar Icon 84 Dan Bollinger Posted December 26th, 2010 - 22:52

    I put the code (above in 1.) in my theme’s regular search.php file and it works just fine. Because I wanted the images to show up at the top of the search results page before blog and page results, I inserted that text at about line 7 after the code that includes “Here are the posts related to…”

    Very nice. I like it that is uses the WP regular search function in my header.

    To get past the double image result I just made sure no two words are included in both the Image Title and Image Tags. Its a simple fix.

    Here is my website with “Cushy” from WooThemes and NGG and NGG-search installed. I only have a few galleries added so far. To test this, search for ‘cat’, ‘horse’, or ‘kokopelli.’ http://www.claycritters.com

    Dan

  85. Gravatar Icon 85 Dan Bollinger Posted December 26th, 2010 - 23:02

    But here’s a strange thing I just noticed:

    If I search for a keyword that is in both a gallery image title/tag AND is also in a post/page, THEN the image thumbnails are shown in the search result page.

    BUT, if the keyword is NOT in a post/page, THEN NO thumbnails are shown even if the keyword is in the image title/tag.

    Why?

  86. Gravatar Icon 86 Steve Posted January 9th, 2011 - 09:08

    4 1/2 months since the author replied. Is there somewhere else we can get answers?

  87. Gravatar Icon 87 Roger Posted January 24th, 2011 - 15:53

    I have been trying to get the search function to do what I want it to do. The site that I’m working on is a stock photography site, without blog posts. I want the search to return results based on keywords. I have accomplished that. What I’m having issues with is I would like the gallery results returned to the page (which I have also accomplished) but when there are no results, a message about no results and the search box. Currently, It returns the message and search box, whether or not there are results.

    I have to say that what I know about PHP will fit on the head of a pin but here is my code so far. I’m sure this is quite simple, but then, so am I!

    <?php printf( __( 'Search Results for: %s', 'twentyten' ), '' . get_search_query() . '' ); ?>


    Any help would be greatly appreciated! Go Pack Go!

  88. Gravatar Icon 88 Roger Posted January 24th, 2011 - 15:55

    Nice-it stripped all the code out-nevermind

  89. Gravatar Icon 89 Jack Posted February 3rd, 2011 - 13:28

    It would be nice to have an option what to search: blog and/or galleries. When I’m on one of the gallery pages I only want to see images in my searchresults, not blog posts.

    I’m also curious to what extend this plugin is being maintained/developed. It’s about the only real gallery plugin that’s part of WP and not an external piece of software.

  90. Gravatar Icon 90 Joanne Posted March 8th, 2011 - 20:56

    Hi I just donated!!!

    I have a custom theme and the search function is not working out of the box.

    Can you suggest how to make it work for a custom theme?

    I added this to functions.php and unzipped NextGenSearch Engine 0.6.0 into /plugins.

    No joy.

    Ideas?

    Thanks

    Joanne

  91. Gravatar Icon 91 Joanne Posted March 14th, 2011 - 19:28

    Alex

    Possible to turn pagination off? Since it’s not working — it would be nice just to see all the images.

    What to change?

    Thanks

  92. Gravatar Icon 92 André Posted March 24th, 2011 - 00:07

    Hi guys. Almost everything working fine (tnx Alex) but i’ve a question/problem.
    The search is working but it still appears the warning that nothing was found. why?
    Thank’s in advance

  93. Gravatar Icon 93 migf1 Posted March 28th, 2011 - 10:50

    This is great, thank you very much for this! Just tested it and it works fine.

    I have a little problem though. I’m using the WordPress Simple Paypal Shopping Cart plugin, with which every picture has a cart trigger code [wpestore:price:25: ... :end] inside its description/alt text. By using the provided (by shopping cart guys) ngg template, each image is presented with shopping cart options beneath it.

    Now, when using the ngg search engine all images are displayed fine but in their description/alt text the shopping cart trigger code is displayed in its raw form (not expanded as cart options, etc).

    Is this an output template issue for the ngg_images_results() function or does it have to do with the cart plugin itself? Is there a way to test ngg_images_results() output using different templates? If so, how? I tried to replace $template=” with $template=’custom-template-name’ inside the source code, without success (I’m no coder, but I think I can pick up any suggestions pretty easily).

    Thanks.

  94. Gravatar Icon 94 stephen mcewan Posted March 29th, 2011 - 18:28

    hi my questions are almost exactly the same as

    @André and @migf1.

    I can find images – using just the tags but the page still displays NOTHING FOUND – when It obviously has.

    also I need the listed found items to have the wp simple shopping cart code and ability to purchase below the images. not just the image – and text once image is clicked.

    also anyone know how to list the tags in a widget – just like post tags ? rather than searching I’d like customers to click on a tag –

    anyone out there help ? anyone there ? hello !

    I’ll pay for Help.

    Thanks

    Stephen McEwan

  95. Gravatar Icon 95 perren Posted April 18th, 2011 - 13:20

    Hi, I was wondering if anybody has came up with any ideas for migf1′s problem?
    I have the same issue. Using the eStore plugin and when I do a search the code that is displayed under the results and not the “Add to cart” button.
    I was told that the search result of this plugin is not filtering wordpress short code.
    I am not a coder, but if anybody can point me to the right direction I would give a try to fix this.

    Thanks a lot

  96. Gravatar Icon 96 Ella Posted May 24th, 2011 - 20:52

    I just want to THANK YOU for such an awesome plugin!!

  97. Gravatar Icon 97 Lee Daniels Posted June 4th, 2011 - 00:19

    Hi all,

    I’ve noticed some frustration with the search plugin and as a result of a thread on the WordPress.org forum as well as several people asking directly, I just wrote an illustrated tutorial for installing and getting the plugin to work. It is on the Code Fixers site at http://codefixers.net

    It should be easy to follow and remove the frustration and confusion that surrounds this issue.

    I hope that it is useful to anybody struggling with this problem!

    Lee Daniels

  98. Gravatar Icon 98 Robin Wyatt Posted June 6th, 2011 - 13:53

    Nice work, Alex! I have this on my site now and it works nicely. However, I’m unclear what the search operators are. I discussed this with Lee Daniels on the WP forums (see towards the end of the thread at http://wordpress.org/support/topic/reading-keywords) and between us, we’ve not been able to figure it out. Could you (or anyone else) shed some light on this?

    Thanks again!

    Robin

  99. Gravatar Icon 99 Blaine Motsinger Posted June 14th, 2011 - 07:00

    Hello,

    I updated to the latest NGG 1.8.0, and this plugin still doesn’t return the correct link in the search results.

    The search finds the correct pid=#, but the link it returns is not correct.

    the image tag is 2127 with pid=781
    if the search was for 2127
    then the search page address is domain.com/?s=2127&x=0&y=0&
    the search result for 2127 is domain.com/?s=2127&x=0&y=0&pid=781

    Again, it finds the correct pid and even the correct picture, but the link isn’t correct.

    Does anyone have any ideas about this issue? I really wish this worked. I’m at the mercy of this. No other search plugin has worked, at all, with pagination turned on.

    thanks,
    Blaine

  100. Gravatar Icon 100 Holger Leyrer Posted June 14th, 2011 - 23:30

    Hello,

    i can’t get it to open up the large picture when clicking on a thumbnail in the search results.
    Any idea?

  101. Gravatar Icon 101 Blaine Motsinger Posted June 17th, 2011 - 03:13

    Note… after digging in (I’m not very well versed at PHP), I think the issue is in the rewrite.php file.

    any ideas… or anyone that has figured this out?

  102. Gravatar Icon 102 Hélio Cristóvão Posted June 27th, 2011 - 16:58

    Hello all,

    @Holger Leyrer
    @Meginoz

    And other users that have this issue:

    Thumbnails link don´t open. I´m also searching for a code fix, any clues by now?

    I´m using Imagebrowser, and (nextgen) permalinks activated. The search is great, and work fully integrated in the theme. Well done! But the thumbs link don´t open.

    Take a look:

    http://www.heliocristovao.net/?s=sintra

    Any solutions by now? I guess all imagebrowser users out there got this problem…

    Thanks,

    Helio

  103. Gravatar Icon 103 Chip Posted July 12th, 2011 - 01:32

    Does this work with the WPMU? If not, is there a way that I can make it work?

  104. Gravatar Icon 104 Andy Posted August 2nd, 2011 - 18:31

    @Hélio Cristóvão: I have the same problem. The Thumb-Link don’t open the image.
    Additionally the integration in the theme isn’t perfect. The top of right sidebar begin at the bottom of search results an the left sidebar is not visible.
    My theme ist “Dark 3Chemical DE”.
    Any solutions?

  105. Gravatar Icon 105 Rebekah Zobel Jones Posted August 7th, 2011 - 00:58

    Perren, Stephen and migf1,

    Any luck with getting the eStore/SimpleShoppingCart shortcodes to process on the search results page? I don’t know enough about PHP to edit the plugin from scratch, but if someone can give me some “shortcode processing code” I can see about tweaking it a bit. Would love to get this working!

    ~R

  106. Gravatar Icon 106 Randy Posted October 1st, 2011 - 21:03

    How do I get this to work with the Twenty Eleven theme?

  107. Gravatar Icon 107 Vanessa Posted October 5th, 2011 - 15:35

    Thank you, thank you, thank you!!! Just what I needed. Works for me perfectly.

  108. Gravatar Icon 108 Brad Kelly Posted December 16th, 2011 - 06:58

    Hi Alex/All,

    Is there a way to modify the extension to combine gallery search results with page/post search results? It seems like if there is a page match, the image results don’t show up.

  109. Gravatar Icon 109 Pixel Posted January 30th, 2012 - 18:52

    Hi and thanks man…great search solution. Just what everyone needed :)
    I’m wondering is there any way to make this search find images by using multi-word search, or more than one term in search box?
    Im sure many people need this…

    If I have two images with descriptions: “nextgen” & “gallery”, for example…
    When type: “nextgen”…it brings image OK.
    BUT, if type: “nextgen gallery” it will say NO RESULTS.
    Is there any way to make it bring both, or more?
    Thanks for support.

  110. Gravatar Icon 110 Pixel Posted January 30th, 2012 - 21:36

    Correction: “… if type: “nextgen gallery” it will say NO RESULTS.”
    In fact, it will not say: NO RESULT, but will bring results template, just will not show any images.

    Hope someone have solution…

    Thanks.

  111. Gravatar Icon 111 Jeff Meadows Posted March 8th, 2012 - 12:00

    Search function working nicely here: http://epfs.org.uk/images/

    How can I apply the caption template to the search results?

    Thanks
    Jeff

Comments are currently closed.