[directimage] new module

battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Sun, 2006-02-12 14:04

Hello together,

I hacked a little module to directly link images without having to use the image IDs(as core.DownloadItem does), but rather use a path and size (like imageViewsIndex on the photo pages). Thus you can directly link images from outside the gallery without having to worry about changing image IDs.
The module is meant for people who use g2 to store their images, but want to display them somewhere else, over a longer time. Now, you could embed an image by using <img src="http://sexy.pirotesse.de/d/8907-2/6497_sacred_wallpaper_800_2.jpg" /> but the problem is, the part after /d/ is the ID for the image and that can change, for example if you rebuild resized images or thumbnails, and then your image cannot display anymore.
The module is also more or less meant for people who do not want to, or can not embed gallery2 in their software, or for whom the gallery integration is too slow (for example for s9y-users).

How does it work?

Quote:
Module for linking directly to images without using the IDs:

- Install the module (needs no configuration) and acitvate it.
After installing a module displaying of images is possible via:
http://my.gallery.com/g2_view=directimage:directimage&amp;g2_path=/albumpath/image.ending&g2_size=sizeindex
g2_path: the path to the album followed by the image name and ending
g2_size: an integer works the same as g2_imageViewsIndex on the photo pages (selected by the photo size dropdown box)

by the way: there are some convenience functions: if you leave out the g2_size parameter or set it too low (below 0) or too high (above the maximum allowed index) or if it is not a number, the g2_size index is set to zero.
g2_path works the same as it does for the photo pages, so you can link to the photo or to the corresponding html.

Demonstration:
http://sexy.pirotesse.de/v/charas/6497_sacred_wallpaper_800_2.jpg.html <-- rewrite module. Downloads an item by path (works without rewrite module, too) Displays a HTML page
http://sexy.pirotesse.de/main.php?g2_view=directimage.directimage&g2_path=/charas/6497_sacred_wallpaper_800_2.jpg.html <-- downloads the image directly. Displays only the image.

Now, the first URL you can not embed into an img-tag. The second you can. (well you should maybe leave out the trailing .html, which is possible with my plugin, too).

Some words of Warning: As you can see large parts of the code come from g2 itself and from the dev tutorial at. The module.inc has been taken from there.
http://txtdump.com/g2dev/
Most of the code in directimage.inc is taken from:
core/DownloadItem.inc and core/classes/GalleryTheme.class
I am not very good with PHP, nor with the gallery code and API itself, so forgive me please if I made stupid mistakes. It should all work allright. I tested it and am using the plugin. There may be issues with permissions, as with my gallery every user can view every item.
Anyways: Feel free to correct what you see wrong, contact me, and ofcourse use it and tell me what you think. :)

directimage.zip is for gallery version 2.0.x
directimage_2.1.zip is for gallery version 2.1RC1

in directimage_2.1.zip some convenience functions have been added:
g2_size=full displays the fullsize version of an image
g2_size=thumb displays the thumbnail version if an image
If any of those should not be possible for viewing, the default version (as if g2_size was set to 0 or left out) will be displayed.

Warning: Versions before 1.0.0 have error2. Please use version 1.0.0 (attached).
Warning: This module may circumvent the fast download cache. I didn't yet notice any negaitve influence on performance and load though.


Gallery version = 2.0.2 core 1.0.0.2 (shoud work with any gallery 2.0.x I think)
PHP version = 4.3.3 apache2handler
Webserver = Apache/2.0.48 (Linux/SuSE)
Database = mysql 4.0.15-Max
Toolkits = ArchiveUpload, Exif, ImageMagick, NetPBM, Thumbnail, Gd (are not necessary, I think)
Operating system = Linux london091 2.4.21-303-athlon #1 Tue Dec 6 12:24:00 UTC 2005 i686
Browser = Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.1) Gecko/20060208 Firefox/1.5.0.1

AttachmentSize
directimage.zip4.13 KB
directimage2.1.zip4.58 KB
 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Sun, 2006-02-12 22:55

by the way:
for easier handling a rewrite rule would be good, I think. I definitely don't know how to do that (yet).

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Sun, 2006-02-12 23:00

I must not understand how your module works but If I'm not wrong it's the same as what rewrite does isn't it ?

Rewrite permit to access items without knowing their IDs, you only need to know their name and where they are(folder). no ?
-------------------------
The Termite :-)

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Mon, 2006-02-13 08:54

Errm, I wouldn't know how. The rewrite module only makes the ID more acessible, since it produces a simple url like this: http://my,gallery.url/d/ID-REVISIONNUMBER/filename.ending

The problem is, you still have the ID in that URL, which is what I really do not need if linking items outside the gallery.
What my module does is get rid of the ID.
http://my.gallery.url/main.php?g2_view=directimage.directimage&path=/albumpath/imagename.ending&g2_size=sizeindex

This is basically what the photo pages do. Here an URL looks like what I do:
http://my.gallery.url/v/albumpath/imagename.ending(.html), but here you get a whole HTML page, where I only want the image. That's the difference.

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Mon, 2006-02-13 12:24

Battlevampiress:

If I understand correctly the module you've offered allows for an external page to link directly to a picture within gallery, is this right?

I've been thinking of extending WPG2 (WordPress Module for Galery2) with LightBox, where clicking on a thumbnail would show the resized-image in an overlay and there a link to the actual gallery. I'm thinking this would make it easier on the gallery2 load when linking from WordPress and would also simplify the flow of seeing the pictures attached to a post.

I'll install the module and let you know.

Thanks

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Mon, 2006-02-13 12:40

Forget it. I have the same problem as with the maps module. I'm using a CVS snapshot of Gallery and the cores have an incompatible version.

I'll have to wait.

Thanks anyway.

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Mon, 2006-02-13 14:39
battlevampiress wrote:
Errm, I wouldn't know how. The rewrite module only makes the ID more acessible, since it produces a simple url like this: http://my,gallery.url/d/ID-REVISIONNUMBER/filename.ending

The problem is, you still have the ID in that URL, which is what I really do not need if linking items outside the gallery.
What my module does is get rid of the ID.
http://my.gallery.url/main.php?g2_view=directimage.directimage&path=/albumpath/imagename.ending&g2_size=sizeindex

This is basically what the photo pages do. Here an URL looks like what I do:
http://my.gallery.url/v/albumpath/imagename.ending(.html), but here you get a whole HTML page, where I only want the image. That's the difference.

This is what I have with the rewrite module:

http://pathtomygallery/v/picname.extension.html here is an example: http://termite.responsiveweb.com/MapModuleTeam/v/Avatar.png.html

I guess it is the same. when I activate the rewrite module I don't have the ID showing up anywhere .... do we have different version of the module maybe ?

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Mon, 2006-02-13 14:56

No, the rewrite module does exactly what you say: it does download an item. But this item includes the surrounding gallery. it's a html page.
My plugin only displays the image.

Demonstration:
http://sexy.pirotesse.de/v/charas/6497_sacred_wallpaper_800_2.jpg.html <-- rewrite module. Downloads an item by path (works without rewrite module, too) Displays a HTML page
http://sexy.pirotesse.de/main.php?g2_view=directimage.directimage&g2_path=/charas/6497_sacred_wallpaper_800_2.jpg.html <-- downloads the image directly. Displays only the image.

Now, the first URL you can not embed into an img-tag. The second you can. (well you should maybe leave out the trailing .html, which is possible with my plugin, too).

eduo wrote:
If I understand correctly the module you've offered allows for an external page to link directly to a picture within gallery, is this right?

Yes. it does allow to link to the image directly without knowing ID. The ID can change, for example when you re-generate the resized- and thumbnail-versions. The worst that could happen with this plugin is, that you suddenly link to an image with the wrong size, when you change the order of sizes in the gallery.

eduo wrote:
I'm thinking this would make it easier on the gallery2 load when linking from WordPress and would also simplify the flow of seeing the pictures attached to a post.

This was one of my considerations, too, but I use it to link images in my blog. So far I had a plugin for that, but the plugin was rather slow, as it issued http-requests against the gallery in order to get the pictures. If you have many posts on one page, that can take quite some time.

eduo wrote:
I'll install the module and let you know.

Please do so. But watch out: I don't know if I maybe would have to do any permissions-checking manually. For my gallery this doesn't matter for the image version, as every user can see every image version. Though when you for example only allow full-size versions vor logged in users, there might be some additional work to do.

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Mon, 2006-02-13 15:06

OOOO I seee. I'm a little slow understanding you know. This is great !

I love this idea of having a way to access the picture directly :-) This might be real usefull for me....

Thanks a lot !! (and sorry for being an idiot)
-------------------------
The Termite :-)

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Mon, 2006-02-13 17:33

Battlevampiress:

I'll have to wait for a new version for the new gallery2.1 to come out. I have that installed right now (long story, Termite has already heard it :) so I can't try anything that doesn't work in 2.1.

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Mon, 2006-02-13 20:34

So: it doesn't work with 2.1? Did I get that right? dammit, that means I'd have to rewrite it then.

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Mon, 2006-02-13 20:37

You got that right.

But I'm not so sure it doesn't work, as it just sees the version requirements to know if it should work or not. Anything earlier than 2.1 is flagged as incompatible (for safety, I guess). I don't know how much have the APIs changed to be sure. Let me try something...

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Mon, 2006-02-13 20:41

No. I just tried changing the versions required just in case the calls were the same but it gave an error.

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Mon, 2006-02-13 21:08

[b]battlevampiress[/b[,

There is a few changes to make for the module to work with gallery 2.1 and the result will not be conmpatible with gallery 2.0 :-)

I do't think there is a "good" way around it but if you look into the documentation there even is a bunch of scripts that would facilitate the transfert from G2.0 to G2.1 compatible.

Good luck !
-------------------------
The Termite :-)

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Mon, 2006-02-13 21:28

Termite:

Did I mention I'm up for testing, if you want to? :)

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
Termitenshort
Termitenshort's picture

Joined: 2005-10-09
Posts: 1894
Posted: Mon, 2006-02-13 22:28
eduo wrote:
Termite:

Did I mention I'm up for testing, if you want to? :)

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

You did and you should be testing something next week end ;)

btw. I haven't seen the feature requests that we talked about in the sourceforge ;)

Now we're getting a bit off topic :D :D :D

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2006-02-13 23:48

Here is info on what needs updating to make it work with current APIs:
http://codex.gallery2.org/index.php/Gallery2:API_Changes_Since_The_Last_Release

I didn't look at the code you wrote, but an alternate approach would be if the Download Item rule in URL Rewrite site admin would let you use %path%... look at the available keywords for Show Item vs Download Item. If %path% were available to DownloadItem then you could make a URL that doesn't need the itemId in it.

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Tue, 2006-02-14 07:44

As soon as 2.1 is stable I am going to port the module - maybe even before that. As I said: I borrowed the code from g2 anyways, so I guess I am going to look how gallery2.1 does the same stuff and adjust my module. It's not that much code. Due to my own stupidity I had to write the module twice anyways, because with the first attempt I overwrote the directimage.inc accidently when packing the module.
What I wanted to say is: For the second attempt to write it, I needed like 2 hours (and that only because at the start I made some msitakes.). So if g2.1 isn't a lot more complex than 2.0.x I should be able to port it pretty fast.

There is another shortcoming my module does not yet address:
I think it does not give you the thumbnails, yet. I could address that problem, too, but I think I will rework the module for gallery 2.1 and then add this missing feature. I just took a quick look at g2.1 and it doesn't look mroe complicated than g2 in this part of the code. Well, maybe a bit more, but a little copy+paste magic from DownloadItem.inc and GalleryTheme.class should work wonders here.

Besides I might use two special keywords the the sizes here too: g2_size=thumb (for displaying the thumbnail) and g2_size=full (for displaying fullsize).
Thus you could access the "critical" sizes easy:
Leaving away the g2_size parameter will display the first resized version (that#s the version you get to see if you first surf to the photo page of an item).
Setting the parameter to full will give you the fullsize version (if allowed. I'll try to work in the proper permission checks. If not allowed fallback to default version, and if that's not allowed, fallback to thumbnail).
Setting the parameter to thumb will always give you the thumbnail.

I think I can do this tonight or ... well if all else fails, you'll have to wait 'till this weekend.

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Tue, 2006-02-14 10:32
mindless wrote:
I didn't look at the code you wrote, but an alternate approach would be if the Download Item rule in URL Rewrite site admin would let you use %path%... look at the available keywords for Show Item vs Download Item. If %path% were available to DownloadItem then you could make a URL that doesn't need the itemId in it.

I took at g2.1RC1 and how downloaditem.inc works there and it doesn't know how to handle the path parameter. But nevertheless I think I have the module finished in a few moments. I am going to try update my gallery version and the module then. Shouldn't take long now.

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Tue, 2006-02-14 10:40

Remember there's no going back to an older version of G2. So you might want to try using a backup version and not your production one.

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Tue, 2006-02-14 11:38

Nah. fallbacks are for losers ;) (Just kidding.)

I updated the plugin to work with version 2.1RC1 - and join the ranks of 2.1RC1 testers. If anything goes wrong, well... I always have a backup of my date available. :)
The new plugin version should work just like the old one, but it should work on gallery2.1RC1 installations (and maybe beyond. I didn't test that.)

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Tue, 2006-02-14 12:31

When I try loading the plug-in I got this when I tried to "Install" it (I had uninstalled and deleted the previous version's directory:

Fatal error: Undefined class name 'gallerystatus' in /Library/WebServer/Documents/eduo/gallery/modules/directimage/module.inc on line 55

After the error I tried reloading the modules page and it was ready to activate, so I think the error is not breaking anything up.

It seems to work now:
http://www.eduo.info/gallery/main.php?g2_view=directimage.directimage&g2_path=/MyLife/Misc-200601/P1050001.JPG.html

Which is the image from:
http://www.eduo.info/gallery/v/MyLife/Misc-200601/P1050001.JPG.html

And displays exactly (yet smaller) as if it was set to g2_size=full:
http://www.eduo.info/gallery/main.php?g2_view=directimage.directimage&g2_path=/MyLife/Misc-200601/P1050001.JPG.html&g2_size=full

Not the resized version, though.

Thumb works OK as well:
http://www.eduo.info/gallery/main.php?g2_view=directimage.directimage&g2_path=/MyLife/Misc-200601/P1050001.JPG.html&g2_size=thumb

How could I work the "resized" image instead of the full one? This one is small, but I have quite some larger ones.

(Also, it still says "My First Module" in the description :)

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Tue, 2006-02-14 12:56

Hah. Funnily, using size "3" (and every number above) works for the resized image:
http://www.eduo.info/gallery/main.php?g2_view=directimage.directimage&g2_path=/MyLife/Misc-200601/P1050001.JPG.html&g2_size=3

Size 1 gives the full size and size 2 the thumbnail.

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Tue, 2006-02-14 13:16

Sorry, there has been an error:
the full g2_size was adjusted erratically to display the fullsize version (O_o - well I guess this happens when you don't know PHP well).
Additionally there has been a problem with errorhandling. If you get the 2.1 module now, it should have version 0.9.9 and this should work. Version 0.9.8 is buggy.

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Tue, 2006-02-14 14:33

Battlevampiress:

It works now. The link without "size" points to the resized image:
http://www.eduo.info/gallery/main.php?g2_view=directimage.directimage&g2_path=/MyLife/Misc-200601/P1050001.JPG.html

The module still gives error upon installation but installs correctly:

Fatal error: Undefined class name 'gallerystatus' in /Library/WebServer/Documents/eduo/gallery/modules/directimage/module.inc on line 55:

55: return array(GalleryStatus::success(), true);

The whole function can probably be taken out as autoconfigure defaults to "true" anyway. You could probably take out the whole block between line 50 and 56, both inclusive.

And it still says "My First Module" in (liine 42 of) module.inc [ $this->setDescription($gallery->i18n('My First module.')); ]

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Tue, 2006-02-14 15:02

Right, GalleryStatus is a leftover from the last version of Gallery. I have to fix this. :) Will be done in a few moments.

And is done now. The directimage2.1.zip attached at the top is what you need. Version 1.0.0 now. It works for me at least now. Thanks for testing.

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Tue, 2006-02-14 15:25

The plug-in is working great now.

I think it would be a good idea to extend the rewrite module to include this in the rules. Currently it doesn't allow %path to be a variable. A variation of %path (%fpath, for example) could point to the jpg file and not the html page that contains it).

This is the normal rule:
d/%itemId%-%serialNumber%/%fileName%

Permalinks can already link directly to filenames, but the items have to be explicitly defined as permalinks. You can take a look at how the sitemap module works, as it enables new entries in the URL rewrite section. The best would probably to add a section to the rewrite screen where the direct links can be defined, for example:

Extending the current "Direct Download" section would probably be too limiting, so a new section for "Direct Download" can be created:

Variable being %fpath and three entries. One for default size, one for thumb, one for fullsize:
i/%fpath
it/%fpath
if/%fpath

Which would translate into the final files:
http://www.eduo.info/gallery/i/Trips/MWSF2003/mwsf-20030109/ack.jpg
http://www.eduo.info/gallery/it/Trips/MWSF2003/mwsf-20030109/ack.jpg
http://www.eduo.info/gallery/if/Trips/MWSF2003/mwsf-20030109/ack.jpg
The first being the default size (resized if it exists), the second the thumbnail and the third the full-size.

With your module installed the following .htaccess URL rewrite rules work:

RewriteCond %{THE_REQUEST} \ /gallery/i/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_FILENAME} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_view=directimage.directimage&g2_path=%1 [QSA,L]

RewriteCond %{THE_REQUEST} \ /gallery/if/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_FILENAME} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_view=directimage.directimage&g2_path=%1&g2_size=1 [QSA,L]

RewriteCond %{THE_REQUEST} \ /gallery/it/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_FILENAME} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_view=directimage.directimage&g2_path=%1&g2_size=2 [QSA,L]

Check the result:
http://www.eduo.info/gallery/main.php?g2_view=directimage.directimage&g2_path=/Trips/SMA-2001/aah.jpg.html
converts into:
http://www.eduo.info/gallery/i/Trips/SMA-2001/aah.jpg.html

And the thumb and fullsizes:
http://www.eduo.info/gallery/it/Trips/SMA-2001/aah.jpg.html
http://www.eduo.info/gallery/if/Trips/SMA-2001/aah.jpg.html

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Tue, 2006-02-14 17:07

Okay, now all I gotta do is how to install rewrite rules. ...Errrm. Anyone got any ideas how to do that or would be willing to extend the setup-function of my module?

Oh and eduo:
RewriteRule . /gallery/main.php?g2_view=directimage.directimage&g2_path=%1&g2_size=1 [QSA,L] <--
RewriteRule . /gallery/main.php?g2_view=directimage.directimage&g2_path=%1&g2_size=2 [QSA,L] <--

this is no good.
this should be g2_size=full and g2_size=thumb, because otherwise it won't work for everyone. :)

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Tue, 2006-02-14 17:16

Battlevampiress:

I got you. Changed it in my file. I'm trying to find the rewrite rules section for modules (starting point: http://codex.gallery2.org/index.php/Gallery2:URL_Rewrite )

I thought "1" and "2" would always point to the correct versions but I might have been mistaken.

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Tue, 2006-02-14 17:38

I have to leave now, but you could take a look at module.inc in the "rewrite" module, where all the basic rules for matching rewrites exist (others like the "sitemap" module may be simpler but the "rewrite" module already has rules set for %path items. You could probably use Rule 0 or Rule 1 (the first is for viewing a single item, surrounded by G2's styles, the second is the current URL Rewrite for viewing photos based on the serialID.

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Tue, 2006-02-14 17:46

battlevampiress,

I have made an effort to document how the rewrite rules can be configured at the URL Rewrite Developer Referene Codex page. If you have any questions don't hesitate to ask.

First off, lets break down how the "original" URL Rewrite rule works. It has %itemId%, %serialNumber% and %fileName%.
itemId - this is the id of the requested item (duh). it is needed in order for fast download cache to work.
serialNumber - to prevent browsers from using their cached version if the file has been modified (ie rotaded - remember rotating pictures in G1?).
fileName - this is only there for show. you don't need it but people might like to know what kind of file they're downloading if you paste the URL somewhere else.

If you remove itemId and use the path instead, like this module does, you'll break the fast download cache code. What this means is that for every page request with, lets say matrix theme with 30 thumbs, you'd get some 30+ request to main.php where the entire framework will be loaded in order to parse the path and map it to an itemId. The "original" URL Rewrite rule is a compromise of efficiency and usability.

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Tue, 2006-02-14 18:56

Pelle:

I understand the decisions behind the original URL rewrite rules but wouldn't it be a good thing to give the user the option to use one or the other?

Also, if a direct link to a "file.jpg.html" is given isn't there a way then to pull the cached image? In the same way that it's being shown by the webpage it could feed the cached, serialized file from the "/album/file.jpg" url.

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Tue, 2006-02-14 21:33

Yeah, of course it'd be great with the option and by all means I encourage you to continue the great work on this module.

The problem with /album/file.jpg URLs is that,
* you need a way to map the URL to some cache file.
* you need a way to manage and keep the cache up to date assuming you don't want to load main.php with the entire framework on every download request.
* you need a way to determine what derivative you want (fullsize/thumb/resize) from parsing the URL, and .sized./.thumb. doesn't work since the item name can contain those strings unlike in G1.
* you need a way to determine what version you want (the serialNumber)

The easy out of the box solution, make %path% possible for download requests. The URL would then look something like
/d/123-4/album/subalbum/image.jpg

But then the way it is now with just the image name looks cleaner and shorter.

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Tue, 2006-02-14 21:56

I see what you mean. This plugin should not be used for setting up alternative thumbnail pages elsewhere as every time the path would have to be parsed by the gallery. The parsing itself shouldn't be THAT complicated on server load - if the calls to the gallery API I use in the background result in leaving out the cache that's not good - but so far it doesn't seem to be totally bad. But I have a server nearly all for myself. ;)
The information about the images are not cached? Sure I need to dig through some arrays, but I've seen big CMS systems do worse. As long the information in those arrays is largely cached I don't see the great problem. Memory consumption might be a bit higher, but that's okay by me. But my grasp on g2 isn't that good.

I don't know how bad that is for g2, I will have to keep an eye on this in the future - thanks for notifying me of this issue.

I tried to stick very closely to the g2 code, but I sure cannot do without the parsing. So far the solution works quick and nice for me, but on the other hand, I do have a rather big server nearly all for myself (I share it with some people, but my page seems so far to eb the most active).

The load I create on gallery should be about the same as if the people would follow links to the photo pages directly (but a page can indeed contain some more pictures), if I understood the code at least somewhat - I tried to use the code from GalleryTheme.class as much as I could, replicating what I saw there, so any caching that is used there, should be used in my code too... however I don't know about the arrays I dig through to get the right images. If these are cached, I can live with the information. If these arrays get fetched from the DB, there is a big problem (but that would be a caching-problem in the gallery-api itself...)

again: thanks a lot for the warning :)

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Wed, 2006-02-15 09:45

Battlevampiress:

As you're using G2's routines (the same ones to display onscreen) and according to some quick checking I did on my server's logs it does seem like your routine is pulling the cached file if it exists or creating a cached file if it doesn't already exist. This is the normal G2 behaviour when seeing items and albums.

Something that does happen is that every query that is normally done for seeing an image (counts, prev, next, etc.) is being done and dismissed, which may indeed put some heavy load into the server (how much depends on the server and the album size).

I currently can find quite a lot of uses for this script (especially with the rewrite rules) for special cases and will keep it. So far it's useful and it can only improve :)

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Wed, 2006-02-15 10:05

I will need to make some loadtesting to find out where the critical amount of readers for a normal blogpage lies (which is usually around 7 posts, each with roguhly 1, sometimes 2 images, usually the amount of images displayed (resized versions) will be around 10.
I'll create a loadtest to see how many users can call this page. I think I have was of a) accessing only the blog to make sure it doesn't cause the load all by itself.
b) accessing blog and images to simulate real life
c) accessing only the images on the front page (or in the feed) to see how g2 behaves

I have a load monitoring tool on my server which has a AMD Athlon(tm) XP 2600+ and 512 MB Ram. I'll check the loads there, so far the server is still bored all thetime, and I also don't see him waiting for I/O .

I am also thinkling of includign your rewrite rule, although I'll think about expanding it a bit. Maybe I'll define a character in the URL I do not use in my images (like Space/%20/+) and use it to seperate the path and size parameters so I can do both in the same URL.

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Wed, 2006-03-01 12:02

Battlevampiress:

Have you found anything. I've been doing some testing, as I'm using directimage to call the images in posts that use lightbox and G2Image in WordPress and unless I'm missing something they seem to always pull the cached images and don't seem to traverse the whole album structure. I haven't checked too rigorously as I've been, precisely, focused on getting LightboxJS Plus and G2Image to work together with G2.

You can see an example post here:
http://www.eduo.info/2006/02/24/star-wars-y-transformers-ahi-man-dao/
The thumbnails are from G2Image and the full-size versions are being pulled through directimage.

So far it seems to work but adding them is not as straightforward as I'd like (but much more straightforward than it was without directimage).

Any plans for updates and/or new features (for example, being able to handle albums :)

Regards,

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Wed, 2006-03-01 12:29

Well, actually no.
I have had some performance issues lately, but that was not due to access to my weblog, which uses the directimage module to get images, but it was due to a spider-attack on my gallery. Someone thought that spidering my site with wget was a good idea.
One wget on my gallery was enough to cause a massive performance impact.
On my weblog I have a few hits every minute, but not all of them pull the images. I never experience any raise in server load, so it is okay for me.
If you don't mind possibly offensive stuff you can look at http://secrets.pirotesse.de to see directimage work.

There are some things I'd like to add to the plugin, like:
an easier way to express directimage links. Something like http://gallery.blah.blubb/di/pathToPhoto#sizeindex , but I don't yet know what would be the best way to do this, and the matter is not pressing to me anymore.

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Thu, 2006-04-13 08:53

This plugin has been tested with Gallery 2.1 - it should work, I encountered no problem so far.
This plugin has been tested with Gallery 2.1.1. It works (at least for me), I encountered no problem so far.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2006-12-25 02:27

UPDATE:
it seems that one of the initial motivations to create this module was that the id of thumbnails and resized images could change when changing thumb/resize settings or rebuilding them in gallery 2.0 and 2.1.
In gallery 2.2, we try to keep the same id where possible. So usually the id shouldn't change anymore. Thus normal URLs might do the job, directimage URLs are no longer necessary for that purpose.
But probably this module has other applications as well, so don't understand this as a call to obsolete this module. I'm just letting you know that some of the problems that have been discussed here should finally be fixed in the core module of Gallery 2.2.

 
eduo

Joined: 2003-09-10
Posts: 107
Posted: Mon, 2006-12-25 12:39
valiant wrote:
UPDATE:
it seems that one of the initial motivations to create this module was that the id of thumbnails and resized images could change when changing thumb/resize settings or rebuilding them in gallery 2.0 and 2.1.
In gallery 2.2, we try to keep the same id where possible. So usually the id shouldn't change anymore. Thus normal URLs might do the job, directimage URLs are no longer necessary for that purpose.
But probably this module has other applications as well, so don't understand this as a call to obsolete this module. I'm just letting you know that some of the problems that have been discussed here should finally be fixed in the core module of Gallery 2.2.

Valiant,

Actually, to me, this module covers a very specific need that sometimes is oversighted. In the same way that you might put a direct URL to a specific page in an album (even if it may change in the future) you may want (in my case, frequently) point to the specific image in that same page (say, to include in a blog post or a forum) and you especifically want to use the easier-to remember name. For these uses the possibility that the image may change places in the future is completely secondary to the accessibility to it NOW (and, actually, may be considered useful).

Currently we may give a link to a specific gallery album page and we don't really mind that page may change in the future. Using a direct link to the image in that page may be in the exact same position. I personally COUNT on directimage to give an error if I change the picture around.

Eduo
---
www.eduo.info
www.eduo.info/gallery/
www.hamsterspit.com

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2006-12-26 03:36

Note that there's the permalink module which creates a persistent URL for items for you which won't change even when you move the item into another album or rename it.

 
battlevampiress

Joined: 2006-02-08
Posts: 21
Posted: Thu, 2006-12-28 23:42

Doesn't the permalink module link to a specific page instead of a specific Picture? (even if the page contains the picture, it still links to the complete HTML page...) But when IDs don't change anymore, indeed, I maybe wouldn't need my module anymore. However for reference by name I might still use it.

About the problem with the redirect: I also tried that... didn't work... and thought I'd solve that problem later. I never did analyze it. :/ Sorry. File it under "known limitations".