You have to choose from an image of your gallery. If you don't want use one of them you can add a new image to the gallery, then click on Gallery settings (Click here for more settings) under the field Preview image choose image from the drop down list!
Paste the bellow code in the template page, where you what to display the preview image of gallery. Don't forgot to change the gallery id.
<?php
$querystr = "SELECT wp_ngg_pictures.*, wp_ngg_gallery.* FROM wp_ngg_pictures, wp_ngg_gallery WHERE wp_ngg_pictures.pid = wp_ngg_gallery.previewpic AND wp_ngg_pictures.galleryid=5 ORDER BY wp_ngg_pictures.pid DESC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
$name=$pageposts[0]->filename;
$path=get_bloginfo('siteurl')."/".$pageposts[0]->path."/".$pageposts[0]->filename;
echo "<img src='".$path."' title='".$name."' width='100' height='75'/>";
?>
Paste the bellow code in the template page, where you what to display the preview image of gallery. Don't forgot to change the gallery id.
<?php
$querystr = "SELECT wp_ngg_pictures.*, wp_ngg_gallery.* FROM wp_ngg_pictures, wp_ngg_gallery WHERE wp_ngg_pictures.pid = wp_ngg_gallery.previewpic AND wp_ngg_pictures.galleryid=5 ORDER BY wp_ngg_pictures.pid DESC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
$name=$pageposts[0]->filename;
$path=get_bloginfo('siteurl')."/".$pageposts[0]->path."/".$pageposts[0]->filename;
echo "<img src='".$path."' title='".$name."' width='100' height='75'/>";
?>
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.