WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: NextGEN Gallery] picpreview (4 posts)

  1. gueblo
    Member
    Posted 5 years ago #

    Hi,

    in the page "gallery settings" i can choose a "preview image". I want to show this preview in the page category.php, but i don't know how to show it.
    I need help.

    Thx :-)

    Gueblo

    -------------

    Bonjour,

    dans la page "gallery settings" je peux choisir une "preview image", c'est-à-dire l'image qui 'representera' ma galerie. Le problème c'est que je ne sais pas l'afficher sur mon site. J'aimerais m'en servir comme "preview" dans la page category.php.

    Quelqu'un saurait-il m'aider ?

    Merci :-)

    Gueblo.

    -------------------

  2. Hiranthi
    Member
    Posted 5 years ago #

    I'm using the following in my portfolio:

    <?php
    function getItemPreview()
    {
    	global $wpdb, $post;
    	$img_cat = $wpdb->get_row('SELECT * FROM '.$wpdb->nggallery.' WHERE gid = '. get_post_meta($post->ID, 'pf_nextgen_gallery', true) .' ORDER by gid DESC limit 0,1');
    	$first_image = $wpdb->get_row('SELECT * FROM '. $wpdb->nggpictures .' WHERE exclude != 1 AND galleryid = '. get_post_meta($post->ID, 'pf_nextgen_gallery', true) .' ORDER by pid DESC limit 0,1');
    
     	$albumPreview = $wpdb->get_results('SELECT pid, filename FROM '.$wpdb->nggpictures.' WHERE pid = '.$img_cat->previewpic.'', OBJECT_K);
    
    	$toppreview = get_option ('siteurl') . '/' . $img_cat->path . '/' . $first_image->filename;
    
    	if ( $previewimg = $albumPreview[$img_cat->previewpic]->filename )
    	{
    		$toppreview = get_option ('siteurl').'/' . $img_cat->path . '/' . $previewimg;
    		echo '<style type="text/css">#image { background-image:url('.$toppreview.')!important; }</style>';
    	}
    	else
    	{
    		echo '<style type="text/css">#image { background-image:url('.$toppreview.')!important; }</style>';
    	}
    }
    ?>

    As you can see I add a custom field pf_nextgen_gallery that stores the ID of the gallery I want the preview of on that page/post. Ofcourse the output can be changed according to your wishes :)

  3. wpjack515
    Blocked
    Posted 4 years ago #

    thanx, illutic

    it's very helpful.

    [spam link removed]

  4. blitz999
    Member
    Posted 4 years ago #

    OK… so where does the above code go? In the page template or elsewhere?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.