Getting ResizedID for all of the items in an album
lvthunder
Joined: 2003-09-12
Posts: 808 |
Posted: Wed, 2006-07-05 00:44 | |||
First let me give some background information of what I am trying to do. I'm trying to use a Javascript program called Lightbox. When you click on one of the images in the album it pops up in the middle of the page without reloading the page. It's a really neat effect. I got it working great with two exceptions. The first is it uses the original image instead of the resized picture. The second issue is that if the user has javascript disabled it would just show the picture. You can see how that was done here. To deal with my two problems I used the code that sewpafly used to get the resize ID to make it use the resized image instead of the full size image. That code is here. Because this Javascript app uses a special tag inside the link tag I need to show links to all the pictures in the album, not just the thumbnails that are on the screen. To do that I have modified the PeerList.tpl file so if there are images either before or after it generates links that have nothing to click on so they don't show up on the album page. Using sewpafly's code at the link above I am able to get the resized ID for all the images that show up on the screen but not the ones that get generated by the PeerList. Does anyone have any ideas on how to do this either a completely different way or how to fix the way I'm doing it so it will work. I have attached my theme and the modified peerlist.tpl file if you would like to take a look. I don't know PHP very well, but I seem to do well with all the smarty templates.
|
||||
Posts: 12
lvthunder, have you had a look at this thread? http://gallery.menalto.com/node/44443 where treqx gets the resized ID with this code in theme.inc
Posts: 808
Yes, I have looked at that but that only works for the images on the current page and not those on the other pages. I'm trying to make a module that gives me what I want but it's kinda going slow since I'm not too good at PHP, but is what I need to do is integrate that code with the code that generates the PeerList callback.
Posts: 19
I followed the same procedure, and I think I figured the resize thing out... I put the following core/callbacks.inc (section between comments only... search for the code that surrounds this addition):
core/callbacks.inc
which adds a $peer.resizeid when peforming a 'LoadPeers' callback.
The benefit is that you can add the following code to PeerList.tpl, and it will properly show all of your images, resized, in the lightbox... spanning multiple pages
PeerList.tpl
Here's a link where you can see it in action...
http://gallery.waun.net
Posts: 808
Perfect. Thanks so much. Instead of editing core/callbacks.inc I made a new module called lightbox and added the PeerList callback there. I'm not sure what the original PeerList in Core is used for. I'm going to try and see if I can't get the module to insert most (if not all) the code you need to get this running. It would be cool if I could make the theme where it doesn't need the theme to be modified at all, but at this point I don't think I can do that.
I also modified the js a little bit so that if the browser has javascript turned off you get the g2 page not just the picture.
Thanks again for getting me past this stumbling block that has kept me stopped for a couple weeks.
Posts: 12
Hey great, thanks a lot. Perfect solution.
Posts: 19
Please keep me posted (here) on the progress of the lighbox module... that's the next logical step to take this, which I was about to start. Maybe I'll just wait and see what you put together.
The only part I can't see being independent of the theme is the part where you have to add javascript to your item titles.
I'm new to the gallery2 project, however, and I can't say I have a good feel of the "big picture", how things interoperate yet. We'll see what happens.
Posts: 808
You can download the module as part of my theme here. The only thing the module does now is has the modified PeerList stuff. This way when you update gallery you don't lose the changes you made to core/callbacks.inc. In the future I want to make it where it will spit out all the javascript calls from the module. I'd also somehow like to modifiy the js so you don't have to edit the image paths. I'm not a javascript or PHP expert. I understand just enough to be dangerous.
In the end I just want the theme author to insert the block at the top and bottom of the page and to modify the link to add the javascript.
Posts: 16
Awesome...has anyone done this with Thickbox though? I saw a post where luxo has thickbox working perfectly on his site??? Havent seen a reponse back from him about his site??
Thanks
Here is Luxo's site >>
http://www.jerware.org/gallery2/main.php
Posts: 19
Out of curiosity... why Thickbox? Here are the tradeoffs, as I see it...
Lightbox Pros:
* Popup window animates when it opens or changes shape
* Forward/Next image overlays with image sets
Thickbox Pros:
* Automatically resizes to fit window
* Can handle non-images
The non-image thing isn't a huge deal for gallery, in my opinion. Might be nice if it handled movies, but that's about it. I think it would be a heck of a lot easier to add automatic resizing to lightbox than to add animation and forward/next to Thickbox.
Are there other advantages to thickbox that I haven't noticed?
==========
http://gallery.waun.net
Posts: 16
I dont know...I think both are pretty nice...I just wanted one that would work easily on any theme....if i could figure out where to add the thickbox/lightbox pieces in the album.tpl file...the script part is easy...just getting it to work in the right areas was the hard part to me. I saw Thickbox as an easier way to open just the pics... but couldn't figure out where to add the code. I wasn't so concerned with next image links or even linking the pics together?? If someone could show me where to add the stuff for any theme really?? Lightbox/thickbox.
Thanks malinator.
Posts: 808
It looks like you just need to change the links in album.tpl and load the js in theme.tpl. It shouldn't be too hard.
Posts: 16
Could you be more specific.?? I"ve seen some of the Lightbox code in here..they change 2 lines in album.tpl file and add some arg statements........I've tried to do the same with thickbox ..no luck yet.
THanks
Posts: 19
Basically, I followed these instructions:
http://gallery.menalto.com/node/50101#comment-189204
Then applied the patch above:
http://gallery.menalto.com/node/51253#comment-193846
Posts: 16
Would anyone be willing to try Thickbox to get it working....that's so much to modify just to get resizing to work when Thickbox will already do it....and not as much modification?? If anyone could try any different theme and just show what you modified. I am thinking all you should have to do is get the thickbox files and place them in a dir somewhere like gallery....then modify theme.inc adding scripts and css stuff/// and then the album.tpl file is where i need help...I see i think what part to replace just cant' get it to work?? Anyone??
Thanks
Posts: 808
Thickbox might resize the image to fit on the sceen. I think lightbox does this too. But your missing the point as to why getting the resized id from Gallery is best. The amount of wasted bandwith that is used if you put a large picture on the page but have the HTML resize it to fit the screen. Some people use Gallery to sell prints with and if they do you don't want someone downloading a 6-10 megapixel image if all they are doing is looking at it on the screen.
Posts: 16
I like the idea...could you put all the steps in one place to get this working for any theme ( lightbox that is )?? jumping from post to post is confusing..
I would appreciate it very much...
Posts: 808
Well here is what I would do to get this working in any theme.
Download the Greypop Theme.
Copy the lightbox.css, js folder and the images lightbox uses from the images folder to your other theme.
Make sure the lightbox module is activated.
Edit theme.tpl (or whatever file has the head part of the template and add this to the head section of the HTML.
Then edit album.tpl or its equivalant and find the places that link the images and make it say.
At the top of album.tpl or its equivalant add this
Then add this to the end of that file
Also edit lightbox.js to point to the correct image paths.
Then finally
You also need to add this to theme.inc
right before the line in the show album page function that says
return array(null, 'theme.tpl');
I think that's it.
Posts: 16
Thanks lvthunder......i get security violation when i add the last 2 steps? If I take them out i see my page and the lightbox opens..no pic though...
Any ideas?? pretty sure i've added the code in the right place?
Posts: 808
hummm
Did you edit the image paths in lightbox.js? I think I forgot that step.
As for the security violation I need to see more then that. Do you have a link?
Also what theme are you trying to add this too.
Posts: 16
Here is the error just trying to access the gallery main page... trying to modify siriux theme.
Yes I did modify those paths..i had messed with Lightbox alittle before...i can get the light box to open sort of...if i take out those last 2 steps..but no pic in the lightbox.
Thanks lvthunder.
The action you attempted is not permitted.
Back to the Gallery
Error Detail -
Error (ERROR_BAD_PARAMETER) : Smarty error: math: parameter x is empty
* in modules/core/classes/GallerySmarty.class at line 107 (GalleryCoreApi::error)
* in lib/smarty/plugins/function.math.php at line 54 (GallerySmarty::trigger_error)
* in /g2data/smarty/templates_c/%%4206357767/%%25^256^25661EA0%%album.tpl.php at line 6
* in lib/smarty/Smarty.class.php at line 1871
* in modules/core/classes/GalleryTemplateAdapter.class at line 709 (Smarty::_smarty_include)
* in /g2data/smarty/templates_c/%%4206357767/%%5D^5D2^5D29E2DD%%theme.tpl.php at line 61 (GalleryTemplateAdapter::theme)
* in lib/smarty/Smarty.class.php at line 1265
* in modules/core/classes/GallerySmarty.class at line 88 (Smarty::fetch)
* in modules/core/classes/GalleryTemplate.class at line 204 (GallerySmarty::fetch)
* in main.php at line 427 (GalleryTemplate::fetch)
* in main.php at line 85
* in main.php at line 78
System Information
Gallery version 2.2-svn
PHP version 5.1.4 apache2handler
Webserver Apache/2.2.2 (Unix) DAV/2 PHP/5.1.4
Database mysqlt 5.0.22-standard-log
Toolkits SquareThumb, ImageMagick, Gd
Operating system Linux dooku 2.6.8-2-386 #1 Tue Aug 16 12:46:35 UTC 2005 i686
Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6
Posts: 808
It looks like the siriux theme does not set the $theme.params.columns so just replace it with the actual number. Also do the same to $theme.params.rows.
Posts: 16
Thanks lvthunder.....I get the lightbox now but no pic is ever loaded. you can check the site out and click onthe 1 pic i have in there..any ideas??
I've double checked my image paths, i may be missing something??
Posts: 808
You also need to add this to theme.inc
right before the line in the show album page function that says
return array(null, 'theme.tpl');
Posts: 16
Awesome...man I appreciate all your help...nice to have someone that helps....Does this setup work though when you click on the actucal image for the album/sub-album?? When I click the image for the album the lightbox opens but no pic
but the link or writing to the side of the pic for the album works perfectly. it opens the pic in the lightbox. THANKS!!!!
Just curious...b/c you can click the pic or the link describing the album...have a quick look if you don't mind on my one album. The album pic vs. the link to the side.
Awesome..thanks again to your lvthunder and all in the forums....the re-sizing works perfectly and its great!!
Posts: 808
There are two problems I see. The first is the on the last page the first two images have an ' in the title. This breaks the lightbox. I need to see if there is a way to fix that.
The second is you need to have an if then statement that talks about if the item can contain children. Look at albumlight.tpl in the greypop theme to see what I mean. If it is there in your theme you just need to take the lightbox part out of that link.
Posts: 16
Is this It??? in the albunlight.tpl>>>>
{if ($theme.item.canContainChildren && $theme.params.showAlbumOwner) ||
(!$theme.item.canContainChildren && $theme.params.showImageOwner)}
{assign var="showOwner" value=true}
{else}
{assign var="showOwner" value=false}
{/if}
****
I've got the first part taken care of, just trying to figure out the canContain.Children part now.
Thanks
Posts: 16
Nevermind lvthunder........I found it. I added the if then else and it works perfectly. I can post if anyone needs it. Where is my album.tpl file i put those.
Now when I click either the picture for the album or the Title words for the album it goes into the album with all the pics.....then if you click on any pic
they are opened in the lightbox.
I am set now. THanks again Lvthunder. With your help i am understanding it better.
Posts: 29
Resurrecting this thread because I was interested in getting Lightbox working in my SearchShowAll.tpl and I figured the solution would be to insert code in SearchShowAll.inc - but I'm struggling to work out exactly how to do it.
SearchShowAll inc does this to get itemIds and thumbnails from the search results:
I figured I could do append a similar "list... = GalleryCoreApi::fetchResizesByItemIds(...)" followed by a foreach loop at that point, but I'm a bit confused about what array to use where, which variables I need to define and which already exist. Trying to use $itemIds is throwing up errors.
Posts: 808
Try putting the code in showmosulepage instead of showalbumpage in theme.inc.
Posts: 29
Cool, thanks for the tip - this works:
Posts: 808
Your welcome. I'm glad it worked.