samtiria / nextgen-gallery

Automatically exported from code.google.com/p/nextgen-gallery
0 stars 0 forks source link

Preview URL is duplicated #373

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create top-level album and a page for it with "extend" mode.
2. Create two  second-level albums inside of top one.
3. Create two galleries - one for each second-level albums and upload at least 
one image into each.
4. Select one of the second-level albums and assign it a preview image
5. Go look at top-level album page

What is the expected output? What do you see instead?
Expected output: first album (the one with a preview) has a preview image, 
second one does not
What I see: both albums have the same preview picture

What version of the product are you using? On what operating system?
1.7.4 nextgen-gallery, Linux CentOS (hosting on hostgator.com).

I edited into album-extend.php file to verify the problem. If I do a print_r on 
$galleries, I can see that previepic ID is being set properly (see below - it's 
303 only for the first object), but previewurl is duplicated from first album 
to the rest of them.

 [a20] => stdClass Object
        (
            [counter] => 0
            [previewpic] => 303
            [previewurl] => http://home.khris.net/wp-content/gallery/2011/2011-04/thumbs/thumbs_DSC08293.JPG
            [previewname] => Everyday
            [pagelink] => http://home.khris.net/?page_id=1077
            [galdesc] => 
            [title] => Everyday
        )

    [a15] => stdClass Object
        (
            [counter] => 0
            [previewpic] => 0
            [previewurl] => http://home.khris.net/wp-content/gallery/2011/2011-04/thumbs/thumbs_DSC08293.JPG
            [previewname] => Kids
            [pagelink] => /?page_id=896&album=15
            [galdesc] => 
            [title] => Kids
        )

    [a13] => stdClass Object
        (
            [counter] => 0
            [previewpic] => 0
            [previewurl] => http://home.khris.net/wp-content/gallery/2011/2011-04/thumbs/thumbs_DSC08293.JPG
            [previewname] => Home
            [pagelink] => http://home.khris.net/?page_id=1085
            [galdesc] => 
            [title] => Home
        )

I also tried moving first album (the one in preview) down. Just as I expected, 
new "first" album stopped having a preview pic, but the rest of them, starting 
from the one with preview, again started having exact same one.

Original issue reported on code.google.com by mrskh...@gmail.com on 7 Jun 2011 at 6:38

GoogleCodeExporter commented 8 years ago
I was able to fix the problem (but not it's root) by changing the following:
nggfunctions.php, line 506:
            if ($subalbum->previewpic > 0)
                $image = $nggdb->find_image( $subalbum->previewpic );

to
            if ($subalbum->previewpic > 0){
                $image = $nggdb->find_image( $subalbum->previewpic );
            }
            else{
        unset($image);
            }

It looks like $image object is not being reset between iterations. Therefore, 
even if there is $subalbum->previewpic is zero, the following line (same file)

$galleries[$key]->previewurl = isset($image->thumbURL) ? $image->thumbURL : '';

still uses previously created $image object.

What I also find strange is that album-extend.php has hard-coded img tag for 
preview - without trying to find out, whether there is a preview file at all.

Original comment by mrskh...@gmail.com on 7 Jun 2011 at 7:02

GoogleCodeExporter commented 8 years ago
Thanks for the report , I will look into this..

Original comment by alex.cologne on 12 Jun 2011 at 9:52

GoogleCodeExporter commented 8 years ago
What's the latest on this?

Original comment by nicdiens...@gmail.com on 19 Oct 2011 at 6:54

GoogleCodeExporter commented 8 years ago
I have been looking into this bug report and can confirm that it exists. The 
proposed code changes also fixes the problem.

I have taken a slightly different approach and have attached a patch which have 
the same functionality. 

Original comment by kristian...@gmail.com on 3 Feb 2012 at 6:54

Attachments:

GoogleCodeExporter commented 8 years ago
THX , done in r1065

Original comment by alex.cologne on 5 Feb 2012 at 5:07