Any way to NOT select highlight photos?

AlpineZone
AlpineZone's picture

Joined: 2004-01-21
Posts: 69
Posted: Fri, 2004-07-16 01:13

I have two albums in my Gallery which only contain sub-albums, not pictures. When the Random Block randomly pulls one of these sub-album's highlight photos for display, clicking on the image will return:

Fatal error: Call to a member function on a non-object in /pathto/gallery/view_photo.php on line 87

Is there any way to have the Random Block not use sub-album highlight photos?

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Fri, 2004-07-16 01:19

Which random block (and which Gallery version) are you using?

 
AlpineZone
AlpineZone's picture

Joined: 2004-01-21
Posts: 69
Posted: Fri, 2004-07-16 02:58

Gallery 1.4.4-RC1, embedded in phpBB 2.0.8. I'm using the random block that is packaged with 1.4.4-RC1, i.e. the block-random.php file.

 
jeffbh

Joined: 2002-12-26
Posts: 38
Posted: Tue, 2004-07-20 08:55

This is a long-standing problem with block-random.php that should (IMHO) really be fixed in util.php by having makeAlbumUrl() test for $photoId being a subalbum, and if so return the view_album URL instead of view_photo.

Until that happens, I suggest tolerating this. The alternative is to do a workaround in block-random.php itself, but that gets messy. Others may have a better solution. The workaround which I implemented, but no longer favor, is to recursively "descend" when a sub-album is chosen until you "hit" a photo. Some people using my version of block-random really like this feature, but it's overly complicated with 1) the security checking needed to make sure you don't go into "hidden" sub-albums (something I--oops--overlooked when I first implemented that solution); and 2) the handling of an album containing nothing but sub-albums. For what it's worth, you can see my version at [url]www.barcahall.com/gallery-block-random.html[/url].

-Jeff

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Tue, 2004-07-20 09:03

Any checks of that sort need to be made by the function caller, not inside the function itself. All it does is return what's asked for.

 
jeffbh

Joined: 2002-12-26
Posts: 38
Posted: Tue, 2004-07-20 09:57
signe wrote:
Any checks of that sort need to be made by the function caller, not inside the function itself. All it does is return what's asked for.

Fair enough. That'll work, too.

-Jeff

 
lancets
lancets's picture

Joined: 2004-07-11
Posts: 15
Posted: Wed, 2004-07-28 02:52

I was getting the PHP Fatal Error too with the release candidates. During RC1 and RC2, I gave up on the block thinking that it was security-related, but when I renewed the effort during RC3, I spotted this thread which seems to be the same issue.
I have a few levels of albums, such as the top level for photo albums for myself and others, then the next level down is albums broken down by year, and the next level down is albums for each event during that year, within which you find photos.
Although I had hoped that this module would randomly choose any photo from the albums, it seems to only choose the highlighted photo from each album. And it does work fine at displaying these highlights randomly, but generates the PHP Fatal Error if you click on the block.
I'm curious if anyone has found that there's something simple to workaround the issue. Or is there any plan to add an option to the include so that you can specify a specific album so that those of us who don't have photos in the top-level albums aren't left out in the cold?

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Wed, 2004-07-28 03:49

Ok.. this is something I've just fixed in 1.4.4. It will be available in the final release.

 
AlpineZone
AlpineZone's picture

Joined: 2004-01-21
Posts: 69
Posted: Wed, 2004-07-28 12:02
signe wrote:
Ok.. this is something I've just fixed in 1.4.4. It will be available in the final release.

That is GREAT news. Thank you!

 
AlpineZone
AlpineZone's picture

Joined: 2004-01-21
Posts: 69
Posted: Wed, 2004-07-28 15:01

I downloaded the new block-random.php file from the CVS and it works great. Any chance you can implement a feature to select particular sub-albums as described HERE?

 
lancets
lancets's picture

Joined: 2004-07-11
Posts: 15
Posted: Wed, 2004-07-28 22:42

From my perspective, I guess it works, as I don't see any 'PHP Fatal Errors.' Now all I get in the block is 'No photo chosen.' It would be nice if it could find a photo, even though they are three levels deep. Even if that meant restricting the random selection to an album or a sub-album so that it didn't have to search so far down. Any possibility of this happening?

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Wed, 2004-07-28 22:49

I could code the random-block to spend all day trying to find an image, but that's not really the point of the thing.. it's supposed to be quick. If the majority of your albums don't contain pictures, you'll run into issues.

All in all, I'm not quite sure what the the big issue is. The random block (that was available from this site) has only been upgraded and fixed since it was added to the code. If you used the original, there were a whole host of issues that you had to deal with that are now fixed.

 
jeffbh

Joined: 2002-12-26
Posts: 38
Posted: Thu, 2004-07-29 00:08

For anyone wanting the ability to specify an album and have random photos come only from that album and its (visible) sub-albums, I have taken the 1.4.4 block-random.php and added that capability, creating a fully compatible version I call block-random-enhanced.php.

-Jeff

 
lancets
lancets's picture

Joined: 2004-07-11
Posts: 15
Posted: Thu, 2004-07-29 06:58

Okay, the new code is working much better. The reason I was getting the 'No photo chosen' at first was because my cache file had not refreshed with the current security settings. (I kept flipping back and forth between secured and unsecured galleries during testing).
Prior to testing this block over the past few weeks, I had protected my galleries so that you could only get in if you were a LOGGEDIN postnuke user. Then I found that the random photo block will only scan for photos in albums that allow EVERYONE. But changing this alone doesn't immediately fix the block and make it work, as the cache file still needs to be deleted or refreshed to find the albums that allow EVERYONE.
Now my only dilemma is to figure out whether I want to open up my security settings to EVERYONE permanently or not. I'd rather have people register before getting into my albums, but then I probably won't be able to use the random block, huh? Any thoughts/suggestions?
Thanks again for all your hard work, signe, as well as the other team members!

 
AlpineZone
AlpineZone's picture

Joined: 2004-01-21
Posts: 69
Posted: Thu, 2004-07-29 16:08
jeffbh wrote:
I have taken the 1.4.4 block-random.php and added that capability, creating a fully compatible version I call block-random-enhanced.php.

Is your "enhanced" version based off the 1.4.4 from the CVS that signe modified so it doesn not pull highlight photos? Any chance the Gallery team will include your version by default? Finally, can you incorporate the default photo frame in your version?

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Thu, 2004-07-29 16:58

Nothing is being changed for 1.4.4, period. It is due to be released tonight/tomorrow if there are no barring issues.

Any work we do on the block-random will probably be done by the team instead of incorporating code, for a couple reasons. The primary one is that everything needs to be coded for option-use in the config wizard. For instance, I don't want image frames or a target (for html frames) in my embedding environment.

 
jeffbh

Joined: 2002-12-26
Posts: 38
Posted: Fri, 2004-07-30 07:17
AlpineZone wrote:
Is your "enhanced" version based off the 1.4.4 from the CVS that signe modified so it doesn not pull highlight photos?

Sub-albums highlights are not returned in my version. The implementation, however is slightly different (predates 1.4.4 but is compatible with it).

AlpineZone wrote:
Any chance the Gallery team will include your version by default?

They really shouldn't. It's a nice, isolated file that is easily supported by an outsider like me, leaving them to focus a little on Gallery 1 and a lot on Gallery 2 (which, btw, is really coming along, from the sample sites I've seen). I plan to keep my version up-to-date with future Gallery 1 releases.

AlpineZone wrote:
Finally, can you incorporate the default photo frame in your version?

My version, if you're not running embedded and you request it, will use the style sheet for your album to set colors and fonts. I'd rather not add more functionality to this code. Perhaps the G2 replacement for block-random will be able to draw the photo frame more easily, given the code modularity of G2.

-Jeff
Maintainer of block-random-enhanced.php