Support » Plugin: NextGEN Gallery - WordPress Gallery Plugin » [Plugin: NextGEN Gallery] PHP functions to resize and chache (like nggSinglePicture)

  • Dear All,

    I would like to add a resize feature for mobile devices, but I can’t find any complete example how to implement it using PHP classes developed by Axel.
    What I would like to have is a resize and caching of resized images the same way it’s done in nggSinglePicture() function, but I’m a bit puzzled on how to apply filters (probably ‘ngg_image_object’), could someone please point me on how to use it, or PHP files to closely look at?

    That’s part of my code:

    $results = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures" . $sql_where . " ORDER BY " . $sql_order . $sql_limit);
    ...
    foreach($results as $result)
          {
            $gallery = $wpdb->get_row("SELECT * FROM $wpdb->nggallery WHERE gid = '" . $result->galleryid . "'");
            foreach($gallery as $key => $value)
            {
                $result->$key = $value;
            }
            $image = new nggImage($result);
            //output in div...
            ...
            <img src=\"" . $image->imageURL . "\"">
            ...
          }
    ...

    p/s/ I noticed that that function is used for DB query

    $picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);

    So I guess my two DB queries can be replaced by this one?

    Sincerely yours,
    Denis.

    http://wordpress.org/extend/plugins/nextgen-gallery/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Reading image.php file, i noticed “cached_singlepic_file”,
    I guess that’s exactly what I need to use:

    $image->cached_singlepic_file($width, $height,'');

    ?

    So, is it safe to do it for some 15-25 pictures? I don’t plan to change sizes often, basically I would visit page once myself to initiate mobile-version images construction, and would not change the size later.

    Any downsides of that idea?

    Finally, I come with a temporary solution to use thumbnails for mobile devices, so I have something like:

    $is_mob = 0;
    if ( function_exists( 'bnc_wptouch_is_mobile' ) && bnc_wptouch_is_mobile()  ) {
        $is_mob = 1;
        }
    ...
    if ($is_mob ==0) {
        $curURL = $image->imageURL;
    } else {
        $curURL = $image->thumbURL;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: NextGEN Gallery] PHP functions to resize and chache (like nggSinglePicture)’ is closed to new replies.