Forum Replies Created

Viewing 4 replies - 16 through 19 (of 19 total)
  • Fantastic, I’ve been looking for something like this for some time.

    My girlfriend had a play with your code and enhanced it slightly because I noted that it didn’t appear to search picture tags, just the name, description and the alt.

    Laura isn’t a SQL / PHP person so the code can probably be made even more efficient.

    I don’t think we added anything extra to what you defined for search.php;

    <p></p>
    <?php if(is_search()) {
    $search = $wp_query->get(‘s’);
    $keywords = preg_replace(‘/\+/’,’ ‘,$search);
    if (function_exists (‘ngg_get_search_pictures’)) { // function from functions.php
    $nggpictures = ngg_get_search_pictures($keywords, ‘6’); // put the number of pictures by row you want, if you don’t want “4”
    if ($nggpictures) {
    echo “<h2></h2>”;
    echo $nggpictures;
    }
    }
    }
    ?>

    Several changes in functions.php;

    ## Function to do searchs on gallery pics from NextGen Gallery plugin
    ##
    ## 2 vars : (1) $keywords (usually coming from the standard search query from wordpress)
    ## (2) $numberPicCol (number of pic by row, if null it takes 4 )
    function ngg_get_search_pictures ($keywords, $numberPicRow = NULL) {
    global $wpdb;
    $count=1;
    if (!$numberPicRow) { $numberPicRow = “4”; }

    $nngquery = “
    SELECT pid,description,alttext
    FROM wp_ngg_pictures
    WHERE MATCH (description, filename, alttext) AGAINST (‘*$keywords*’ IN BOOLEAN MODE)
    AND exclude = ‘0’
    UNION
    SELECT pid,description,alttext
    FROM wp_ngg_pictures, wp_ngg_tags, wp_ngg_pic2tags
    WHERE pid = picid and tagid = id and
    MATCH (name) AGAINST (‘*$keywords*’ IN BOOLEAN MODE)
    AND exclude = ‘0’
    “;
    $pictures = $wpdb->get_results($nngquery, ARRAY_A);

    if ($pictures) foreach($pictures as $pic) {

    $out .= ‘‘;
    $out .= ‘<img class=”ngg-gallery” style=”border: .1em solid #FFFFFF” src=”‘.nggallery::get_thumbnail_url($pic[pid]).'” alt=”‘.stripslashes($pic[alttext]).'” title=”‘.stripslashes($pic[alttext]).'” />’;
    $out .= “
    \n”;
    if ($count == 0) {
    $out .= “”;
    }
    ++$count;
    $count%=$numberPicRow;
    }
    return $out;
    };

    Hope the code posts OK?

    I’m redeveloping my website but you can see the code in practise here, https://blog.aengusm.com/?page_id=24 not many pics there at the moment so just enter a single letter like a in the search box.

    Hope that adds something for someone.

    Cheers,

    Aengus

    Good on ya Alex! Thanks!

    Alex, those couple of $$’s are well deserved!

    In my naivety, yes I may be looking for a photoblog?

    Initially I was after a page with all images as thumbnails.

    On reflection, what I should really be looking for is a search page based on keywords associated with the images.

    For example if I have an image of a Shark in Blue Water taken in The Solomons (I’m into Underwater Photography), I can associate the keywords Shark, Solomon Islands and Blue Water with that image, and then search by any of those keywords to return a page of thumbnails?

    Hmmm, possibly looking for something that is beyond reasonable spec’s for Nextgen or something for the wishlist?

    Aengus

    https://www.aengusm.com

    Fantastic Plug-in Alex, thank you!

    My first question re NextGen (and a reminder that I need to contribute a few $$’s to you!)…

    [slideshow=0] inserts a slideshow of all images, is it possible to insert all images as single images and subsequently manage the number per page?

    Maybe this should be in the wishlist? Was also thinking about an ability to set categories for images from which searches can be performed? While I want to insert images in my blog I also am looking to have a searchable databases of all images.

    Cheers,

    Aengus

Viewing 4 replies - 16 through 19 (of 19 total)