I tryed it but it doesn't work with dynamic albums. The reason is that `getFirstImageURL()` uses `getImage(0)` and in this function there is a different result if the album is dynamic. I think I can rebuild the URL according to this. I'll try at least..
Try the class object methodes then. Create a new album object of the album you want, then get its images and create an image object for the first image. Then you can use the image class methodes to get the link.
I think that you are true anyway, getFirstImageURL() should work also with dynamic albums. I possibly found a bug in getImage($index) function in album class-album.php: `return newImage($album, $images['filename']);` should be: `return newImage($album, $images[$index]['filename']);` If not I get an Undefined index notice when I call it from getFirstImageURL() while in dynamic album context.
Then the URL in getFirstImageURL() function should be modified for dynamic albums to have a link to the right static album containing the image.
May be I'm going beyond my knowlege and my possibilities, if so be patient with me please
Your fix looks good, but I will check the code to be sure. I guess that this is just one of those things that was overlooked and never reported until now.
I hope this helps, anyway my goal is far too hard for me. What I'm tryng to do is to have a direct link to the first image of a dynamic album in my index page.
I was able to get the first image of a given dynamic album using the above fix and rewriting the URL in a custom function, stored in a plugin: getMyFirstImageURL().
But of course after that i fall in the static album's image page and i can't browse my dynamic album using the next button.
I am not sure there is an easy way to make a link to an image and have it appear to be in a search/dynamic album. You would have to store the search params cookie first, but that will work only for one image/dynamic album.
I found a very dirty way, but it means that it's possible somehow. The image page with the first image of dynamic album is called from a link on index page, which also passes a variable, like: `?var=value1` When in image.php if `$var="value1"` it sets the proper cookie before any output but then for some reason it needs a refresh to the same page, set the cookie again and then it works. To get out of the refresh loop I make it change $var to "value2" in `header("location: $mypage?var=value2")` Too bad to use it in a real site, but this suggest to me that the reason why it doesn't work the first time I call the image page may be a matter of context. Any suggestion to clean this routine?
It didn't work, but made me found a solution. I'll explain it here to share with other people and also to have your opinion about compatibility with future versions of zenphoto. After setting the cookie I created `$_zp_current_search = new SearchEngine()` and stored the proper search parameters (as in the cookie) in $_zp_current_search. Then I set the proper context, i.e. 167 or `set_context(ZP_SEARCH_LINKED | ZP_IMAGE_LINKED | ZP_IMAGE | ZP_INDEX | ZP_ALBUM)`
Comments
I possibly found a bug in getImage($index) function in album class-album.php:
`return newImage($album, $images['filename']);`
should be:
`return newImage($album, $images[$index]['filename']);`
If not I get an Undefined index notice when I call it from getFirstImageURL() while in dynamic album context.
Then the URL in getFirstImageURL() function should be modified for dynamic albums to have a link to the right static album containing the image.
May be I'm going beyond my knowlege and my possibilities, if so be patient with me please
What I'm tryng to do is to have a direct link to the first image of a dynamic album in my index page.
I was able to get the first image of a given dynamic album using the above fix and rewriting the URL in a custom function, stored in a plugin: getMyFirstImageURL().
But of course after that i fall in the static album's image page and i can't browse my dynamic album using the next button.
The image page with the first image of dynamic album is called from a link on index page, which also passes a variable, like: `?var=value1`
When in image.php if `$var="value1"` it sets the proper cookie before any output but then for some reason it needs a refresh to the same page, set the cookie again and then it works. To get out of the refresh loop I make it change $var to "value2" in `header("location: $mypage?var=value2")`
Too bad to use it in a real site, but this suggest to me that the reason why it doesn't work the first time I call the image page may be a matter of context.
Any suggestion to clean this routine?
I'll explain it here to share with other people and also to have your opinion about compatibility with future versions of zenphoto.
After setting the cookie I created `$_zp_current_search = new SearchEngine()` and stored the proper search parameters (as in the cookie) in $_zp_current_search.
Then I set the proper context, i.e. 167 or `set_context(ZP_SEARCH_LINKED | ZP_IMAGE_LINKED | ZP_IMAGE | ZP_INDEX | ZP_ALBUM)`