Simpleviewer module

LastQuark

Joined: 2007-07-25
Posts: 4
Posted: Thu, 2007-07-26 04:37

Hi, my first post here.

Is there a module for a better slideshow like Simpleviewer or Flashnifties?

I was actually surprised these slideshows are not yet a module of G2.

Thanks.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2007-07-26 15:41

http://www.flashyourweb.com/index.php
from the developer of the flash movie player.
He has a mini slideshow and its big brother as well.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2007-11-01 16:58

I'm writing a simpleviewer plugin. First version should be ready in a couple of days.

 
LastQuark

Joined: 2007-07-25
Posts: 4
Posted: Thu, 2007-11-01 20:13

That is excellent. I can't wait. Please keep us posted.

Rgds.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2007-11-13 15:03

OK folks, here it is, my first ever contribution to an GPL'd project.

What it is: a basic interface to allow Simpleviewer (http://www.airtightinteractive.com/simpleviewer/) to load its pictures from a Gallery2 installation. Simpleviewersource is a small module that produces the xml output that simpleviewer uses.

What it isn't: a full gallery theme based around Simpleviewer, although it might be useful if someone wanted to create one.

What is also is: a bit rough. I may not have ironed out all the bugs, and there may be some coding nastyness - consider this an alpha version. My helmet strap is tightened and I am ready to face the brickbats.

Installation and setup is obvious: use the admin page to set the <simpleviewer></simpleviewer> parameters, then in your webpage where you want simpleviewer to load, use this line in the javascript loader, substituting for your own Gallery installation and the item_Id of the album with the pictures:

fo.addVariable("xmlDataPath", http://www.yourGallery.com/main.php?g2_view=simpleviewersource.XMLOut%26g2_itemId=xxxxx");

You can override the global simpleviewer parameters in the Admin page on an hierarchical sub-album overrides album basis, using the CustomFields module. Create an album field called "simpleviewersource" and in it place the parameters that should be used: thus for example:
navPosition='bottom' frameColor='0x0000ff'

An additional configuration option (not currently overrideable) is a limit to the number of items to show. Simpleviewer isn't designed for large albums and can trash the performance of your pc by loading hundreds of photos. So the Admin page for this module includes a way to limit the number of photos shown to the first 'n' in any album.


Notes:

  • You need to know the albumId: you can read this from the url of the album if you turn off URL Rewrite.
  • The code of Simpleviewer demands the same 'filename' for the image as for its thumbnail. It is, however, quite happy to create thumbnails of the right size on the fly. Since the download path for a thumbnail from Gallery isn't simply related to the main image URL it would be tricky to use Gallery's thumbnails as simpleviewer's too. So I haven't. [fixed from 0.1.1]
  • g2_view=core.DownloadItem which is used as the imagepath does not appear to honour the watermark status of images. (Why, anyone?) So watermarks don't seem to show up even when they're set. However given the point above about thumbnails, it means that the thumbnails stay watermark free.[done]
  • The per album override method is really hacky: simpleviewer (apparently) uses the first declaration of any parameter; all this module does is stack up all the custom fields in ascending hierarchy without parsing and removing duplicates. That'll be something to fix.[done]

Ideas for the future:

  • Allow a configuration of which size image to supply to simpleviewer, where a choice exists in an album. Or generate a given size on the fly.
  • Allow per album options via a dedicated simpleviewersource tab on the 'Edit Album' page [done]
  • Allow selection of albums by other methods not requiring the itemId
  • Build a theme around simpleviewer, using this module as the core to display the images
  • Translations

Please try this out, and let me know how it goes. All corrections, bugs, suggestions etc gratefully received. Acknowlegements to turnbulm, jayhen and others for the inspiration and for chunks of code lifted and modified from their Checkout modules.

[edit] for the latest version see this page:
http://codex.gallery2.org/Gallery2:Modules:simpleviewersource

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-02 17:14

I've now found a solution for downloading Gallery's thumbnails instead of having simpleviewer use the full size image - this makes loading faster. I'll post version 0.1.1 later on (5 hours ... how's that for a product development cycle :-) )

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2007-11-02 17:36

I have created a codex page ( only boilerplate info at this time ):
http://codex.gallery2.org/Gallery2:Modules:simpleviewer
please update it as required.
Thanks for the contribution.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2007-11-03 00:30

Issues with permissions now fixed - the image downloaded to simpleviewer is in order of preference and according to the permissions set at the time of downloading, the full size image, the first resize, or (last resort) the thumbnail.

Thumbnails are now downloaded correctly also.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2007-11-08 13:33

Version 0.2.2 now ready...

Improvements:

  • Module no longer needs a siteAdmin page but has a page under Edit Album, where all options are set hierarchically. So set them in the root album, and override in sub and sub sub albums.
  • You can enter the name of custom parameters (for those people who've customised Simpleviewer, like me) on each page too.
  • Custom parameters entered in any album are offered to you as options for every other album; you don't need to type the parameter name in again.
  • You can disable Simpleviewer for any album or part of the album tree.
  • the config page displays the correct url to put into simpleviewer for the album in question so you can copy-and-paste.

There seem to be two options for getting the image; either source it directly, replicating some of the code from the core.DownloadImage view, or issue a 307 redirect and have the browser (on behalf of simplevier) re-request each image and thumbnail. Both work, both have pros and cons, and interact with the browser cache differently. Currently the code redirects; to use the other method comment out these two lines in the DownloadMax.inc and DownloadThumbnail.inc files:

	header("Location:$mainUrl", TRUE, 307);
	exit();

There may be some more bugs lurking, please let me know if you use this module.

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Thu, 2007-11-08 23:39
Notice: Undefined index: true in /var/www/<path>/gallery2/modules/core/classes/GalleryUrlGenerator.class on line 421
Notice: Undefined variable: moduleParams in /var/www/<path>/gallery2/modules/simpleviewersource/XMLOut.inc on line 106
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/<path>/gallery2/modules/simpleviewersource/XMLOut.inc on line 106

Is the error I'm seeing when opening http://example.com/gallery2/main.php?g2_view=simpleviewersource.XMLOut&g2_itemId=7 on my test site, running current Gallery 2 SVN trunk.
Needless to say, Simpleviewer can't process it ;-)


h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-09 00:25
Quote:
Notice: Undefined index: true in /var/www/<path>/gallery2/modules/core/classes/GalleryUrlGenerator.class on line 421
Notice: Undefined variable: moduleParams in /var/www/<path>/gallery2/modules/simpleviewersource/XMLOut.inc on line 106
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/<path>/gallery2/modules/simpleviewersource/XMLOut.inc on line 106

Is the error I’m now seeing.

Fixed the Undefined variable warnings, thanks. Not sure about the Undefined index though

Quote:
Missing some capital letters. Around line 133, it should be

if (get_class($myItem)!='GalleryPhotoItem') {

instead of galleryphotoitem

fixed, thanks

Quote:
Ahh. It doesn't deal with being embedded correctly.
It's making the thumbpath
thumbPath=' http://localhost/wordpress/main.php?g2_view=simpleviewersource.DownloadThumb&g2_itemId='
When it should be
thumbPath=' http://localhost/wordpress/photo_gallery?g2_view=simpleviewersource.DownloadThumb&g2_itemId='
I'll keep playing with it.

I've rewritten the way urls are generated but I don't have an embedded gallery to test it on, so please feel free...

Quote:
Ok. Well, I now have output from XMLOut.inc

<?xml version="1.0" encoding="UTF-8"?><simpleviewerGallery maxImageHeight='480' maxImageWidth='640' textColor='ffffff' frameColor='000000' frameWidth='800' stagePadding='20' navPosition='0' thumbnailColumns='3' thumbnailRows='3' title='Photo Gallery' thumbPath=' http://localhost/fred/main.php?g2_view=simpleviewersource.DownloadThumb&g2_itemId=' imagePath=' http://localhost/fred/main.php?g2_view=simpleviewersource.DownloadMax&g2_itemId=' >
<image><filename>25</filename><caption>kirk</caption></image>
<image><filename>28</filename><caption>G2image_screenshot</caption></image> 
<image><filename>50</filename><caption>Blue hills</caption></image>
</simpleviewerGallery>

That all looks correct.

But when I test it with simpleviewer/index.html, it says, "Gallery Not Found." Have you seen this? If so, can you point me in the way of a solution?

"Gallery Not Found" (I think) means that Simpleviewer isn't receiving the XML. (If it gets the XML but fails to load any images you get X's instead of pictures). Can you post exactly what you put in your index.html? (Did you escape the & in the url fed to Simpleviewer to %26?)

Check also (in case of more issues) that
http://localhost/fred/main.php?g2_view=simpleviewersource.DownloadThumb&g2_itemId=25 downloads a thumbnail
and
http://localhost/fred/main.php?g2_view=simpleviewersource.DownloadMax&g2_itemId=25 downloads the same image.

(both those URL's should generate a 307 redirect to take you to the right url.)

*new XMLOut.inc attached*

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-09 00:39

Alec,

I downloaded SimpleViewer 1.8 from here.

Then in simpleviewer/index.html, I changed

fo.addVariable("xmlDataPath", "gallery.xml");

to

fo.addVariable("xmlDataPath", "http://localhost/wordpress/photo_gallery?g2_view=simpleviewersource.XMLOut&g2_itemId=7");

Where http://localhost/wordpress/photo_gallery?g2_view=simpleviewersource.XMLOut&g2_itemId=7 is the file that is giving me the good output shown in your post.

The whole <div> looks like this

	<div id="flashcontent">SimpleViewer requires Macromedia Flash. <a href="http://www.macromedia.com/go/getflashplayer/">Get Macromedia Flash.</a> If you have Flash installed, <a href="index.html?detectflash=false">click to view gallery</a>.</div>
	<script type="text/javascript">
		var fo = new SWFObject("viewer.swf", "viewer", "100%", "100%", "7", "#181818");
		fo.addVariable("preloaderColor", "0xffffff");
		fo.addVariable("xmlDataPath", "http://localhost/fred/main.php?g2_view=simpleviewersource.XMLOut&g2_itemId=7");
		fo.write("flashcontent");
	</script>

It works on the SimpleViewer demo data in gallery.xml, but it says it can't locate the gallery when I feed it XMLOut.inc.

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-09 01:03

Just a thought...

If the path to the swf file is such that Flash thinks the xml file is coming cross-domain it requests a crossdomain.xml file (see http://www.crossdomainxml.org/) for permission to load it: try adding this file to your localhost's root www directory:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
   <allow-access-from domain="*" />
</cross-domain-policy>

And call it crossdomain.xml

If that doesn't help, any chance you could use something like the Firefox Live Http Headers plugin to see what url Simpleviewer is actually requesting?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-09 01:07

...oh, and change the & in the xml url to %26 thus:

fo.addVariable("xmlDataPath", "http://localhost/fred/main.php?g2_view=simpleviewersource.XMLOut%26g2_itemId=7");
 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-09 15:45
alecmyers wrote:
...oh, and change the & in the xml url to %26 thus:

fo.addVariable("xmlDataPath", "http://localhost/fred/main.php?g2_view=simpleviewersource.XMLOut%26g2_itemId=7");

Changing the & to %26 worked. It's now loading the thumbnails. There was no need for the crossdomain stuff, since it's all on localhost.

Now the problem is that the fullsized images are not showing up. I'm only getting the three thumbnails on the left of the page and no large images at all, either on initial page load or when clicking on the thumbnails.

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-09 16:02

Kirk,

Do you see x's instead of the large images, or just nothing at all? How many thumbnails/images are you expecting? How many images are in the album in question?

Please try downloading through your browser the images "manually" using the URLs from the xml stream. In detail: pull out the two images paths for thumbnails and full-size images and suffix the itemId of the images, so you should have something like:

http://localhost/fred/main.php?g2_view=simpleviewersource.DownloadThumb&g2_itemId=xxxxx

and

http://localhost/fred/main.php?g2_view=simpleviewersource.DownloadMax&g2_itemId=xxxxx

Let me know what you get.

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-09 16:18

Alec,

I'm only expecting the three thumbnails I'm getting. It's a small test album. The thumbnails are actually showing up as images, not X's.

I installed the Firefox Live Http Headers plugin and looked. (Great plugin, by the way.) The call and reply are going out for the correct fullsized images. Example:

http://localhost/fred/main.php?g2_view=simpleviewersource.DownloadMax&g2_itemId=28

(/fred/ is my dev box Gallery2 directory. I renamed it to make sure that WPG2 was not dying if it was not /gallery/ or /gallery2/ for its autovalidation scripts while troubleshooting WordPress/Gallery2 URL rewrite coordination.)

If I copy that to my address bar, it brings up the correct image. So, it looks like it's getting there, just not displaying.

I'm thinking maybe some of my SimpleViewer settings may not be right. I've attached a screenshot of what I put in. Again, this is where a default set of known working settings would be great.

EDIT: I unset all of the settings, except enabled, and it's working now in /simpleviewer/index.html. :) I also now have it working in a WordPress post. It's very cramped, so I'll have to play with the CSS some. How did you get the moving slideshow effect on the sample page you sent me?

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-09 17:33

Glad that it works!

Re the parameters: I'll have the activation procedure insert sensible options for the root album (although most of them you can leave blank.)

In the mean time, they are all described best at the simpleviewer page here:

http://www.airtightinteractive.com/simpleviewer/xml_options.html
so for instance, textcolor should be 0xffffff, not ffffff
Nav position should be one of {top, bottom, left, right}

The moving slideshow is a modification of mine to the simpleviewer code (you pay $45 or something and you get the code to hack about with). Unfortunately it's not GPL'd so I can't send it to you but I did describe the mods necessary the simpleviewer support forum at the airtightinteractive website. (I think I added the zoom and slide afterwards along with a load of other stuff too - but I can go through it with you if you want to get hold of the source code.)

Anyone else still having problems getting this to work?

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-09 17:50

For the parameters that have fixed choices, like navPosition, it would be good to have a pulldown selector that limits selection to the valid choices. It would also be good to have error checking in the options to check for 0xffffff instead of ffffff.

No problem on the moving slideshow. There are other free scripts to do that with.

One thing I noticed (see attached screenshot) is that the fullsized images are the originals instead of the preferred derivatives, which include watermarks. The large image should have the same "Steffensenfamily.com" watermark in the lower right-hand corner. I had the same problem in G2Image. See this thread for the code I used to fix it. Your mileage may vary. I haven't looked at your code to see how well it matches.

(I don't actually use watermarks on my family website, but it's a good idea to include them on your dev box, because a lot of people do.)

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-09 19:34

Kirk,

I thought about parameter checking, pull-down menus or radio buttons etc - I decided against as Simpleviewer must do its own, may have new options added in the future, and I didn't want to constrain the user. (Also I didn't want to spend a week writing and testing pages of special code for all the different options, I figured if someone was savvy enough to hack around in the html and cut and past the java scripts into the page headers etc they'd want to look through the customization options to get the right syntax - does that make me a horrible person? )

Preferred derivatives: definitely you have a point. I've coded it to use the original, then the resize, then lastly the thumbnail according to which permissions are set. I do need to look into the preferred derivative (where's it set?) because unlike you I *do* use watermarks and at present some of the images are being served without them when I don't want them to be. However aside from the watermarks it makes sense to let simpleviewer adjust the picture to the size - you've specified the max image dimensions in the options already. I will definitely look at your code in detail though, it should be very straightforward to adjust the DownloadMax view.

Actually to tell you the truth, I was surprised that core.DownloadItem will actually serve the image without a watermark when one is set on the original size, it makes it pretty trivial to subvert the watermark entirely, but that's a side issue.

By the way - there is a choice in simpleviewersource either to issue a 307 redirect and let the browser download from the new url for the image, or else to serve the image file directly (I confess I cribbed code from the core.DownloadItem module as there's no convenient interface at the right point) - any thoughts?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-09 19:47

Ok, here's the latest collection of changes:

  • The copy-and-paste-me url in the simpleviewersource tab has the & escaped to %26 for easier setup
  • Configuration after installation inserts a minimal working set of options into the root directory
  • couple of other random fixes, as detailed above
 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-09 21:13

Line 143 of XMLOut.inc still had all lowercase on the item class, like this:

	    if (get_class($myItem)!='galleryphotoitem')  {

It needs caps, like this:

	    if (get_class($myItem)!='GalleryPhotoItem')  {

Other than that, it worked well out of the box.

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Fri, 2007-11-09 23:00

I still have problems with the new version (I've added the changes capt_kirk mentioned above), as the XML file created is not well formed:

http://sandbox.p0ggel.org/gallery2/main.php?g2_view=simpleviewersource.XMLOut&g2_itemId=65094

For some reason the g2_itemId is empty in the thumbpath.


h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-09 23:36

h0bbel,

As mentioned above, you absolutely *must* escape the & in the xml url, thus this is what you should set the XMLDataPath variable to:

http://sandbox.p0ggel.org/gallery2/main.php?g2_view=simpleviewersource.XMLOut%26g2_itemId=65094

Otherwise simpleviewer will remove the variable part of the url, and fail to find the gallery.

Aside from that, the output from your website (as per the url you posted) looks well formed to me, if not in xml terms then at least in terms of what Simpleviewer will parse. The thumbpath in the <simpleviewer> object ends with "g2_itemId=" by design; Simpleviewer requires a directory and a filename which are concatenated to get the source for each image; very well then, we're passing the full image url in two parts, the second of which is the item id as listed under <image><filename>... and the first part is the rest of the url, up to and including the =.

I've pointed simpleviewer at this link:

http://www.cerocphotos.com/sv2/ho.html

to download your xml source, but you're not serving a crossdomain.xml from the root of your server - if you add that file (details above) I hope that it should be able to load your images. Either way, point your own simpleviewer towards the url you listed (changing the & to %26 as I said) and see what happens - it looks healthy to me.

I've just checked and the images download fine, under the urls built from the thumbpath and imagepath combined with the itemIds. Although the & keeps getting escaped when I paste them into firefox.

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Sat, 2007-11-10 00:13
h0bbel wrote:
For some reason the g2_itemId is empty in the thumbpath.

That threw me at first, too. But both thumbpath and imagepath are the leading part of the path that is appended to the id supplied for each image. If you're using Firefox to look at your XML page, look at the page source. There is more behind it that doesn't display on firefox for some reason. Here's what I got for your page:

<?xml version="1.0" encoding="UTF-8"?><simpleviewerGallery maxImageHeight='640' maxImageWidth='640' textColor='#ffffff' frameColor='#ffffff' frameWidth='640' stagePadding='5' navPosition='left' thumbnailColumns='3' thumbnailRows='3' title='moblog' thumbPath='http://sandbox.p0ggel.org/gallery2/main.php?g2_view=simpleviewersource.DownloadThumb&g2_itemId=' imagePath='http://sandbox.p0ggel.org/gallery2/main.php?g2_view=simpleviewersource.DownloadMax&g2_itemId=' >
<image><filename>65097</filename><caption>office.jpg</caption></image>
<image><filename>65101</filename><caption>xmaseve-cover.jpg</caption></image>
<image><filename>65103</filename><caption>Picture007.jpg</caption></image>
</simpleviewerGallery>

The filename attribute is appended to both the thumbpath and the imagepath for getting the thumbnails and the images. So, it looks like the item id is empty, but it's really just a prefix.

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Sat, 2007-11-10 00:20

Ah, then the feed is fine. Simpleviewer still doesn't show it though, http://sandbox.p0ggel.org/simplev/

And, yes, the & is escaped properly in the SimpleViewer config file, I just opened it unescaped in FF for debugging. Believe it or not, I've read readmes before. ;)

Now, my Gallery 2 event log shows me the following:

 Error (ERROR_BAD_PARAMETER)in modules/core/DownloadItem.inc at line 58 (GalleryCoreApi::error) 
in main.php at line 437 (DownloadItemView::renderImmediate) 
in main.php at line 103
in main.php at line 88

Request variables: Array
(
    [view] => core.DownloadItem
)

h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sat, 2007-11-10 23:24
h0bbel wrote:
Ah, then the feed is fine. Simpleviewer still doesn't show it though, http://sandbox.p0ggel.org/simplev/

And, yes, the & is escaped properly in the SimpleViewer config file, I just opened it unescaped in FF for debugging. Believe it or not, I've read readmes before. ;)

Since When :-)
____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Sat, 2007-11-10 23:44

The 24th of March, 1994 IIRC

:-)


h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2007-11-11 13:24
h0bbel wrote:
Now, my Gallery 2 event log shows me the following:

 Error (ERROR_BAD_PARAMETER)in modules/core/DownloadItem.inc at line 58 (GalleryCoreApi::error) 

OK,I think I've got it... you're not using the URL rewrite module for download URLs, and simpleviewersource.DownloadMax and simpleviewersource.DownloadThmb were escaping the & in the URL they were redirecting your browser to for each image, to &amp; which failed when passed back to core.DownloadItem by the browser.

I've changed the parameters to generateURL - hope this should work now. Please test and let me know.

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Sun, 2007-11-11 19:07

Thats right, I don't have rewrite enabled on my sandbox. I'll test it some more later on tonight.


h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Sun, 2007-11-11 22:01

Excellent, the last updates fixed that issue. I still can't get anything but thumbnails working though?


h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2007-11-12 10:54

In the XML stream from your installation it looks like the frameWidth parameter is set to 640 - frameWidth is the width of the (usually white) border around the main image, a more suitable value is 40. A value of 640 won't give simpleviewer space on anything but a humungous screen to display a main image at all. From experimenting at this end, I suspect it's a typo in your parameter settings. (Also, textColor and frameColor should be 0xffffff rather than #ffffff although I believe an error there just causes them to use the default which is white in any case.)

With any luck that should be working now!

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Mon, 2007-11-12 18:34

I set the maxImageHeight and maxImageWidth to 640, not the frameWidth which I didn't set at all. I didn't set textColor or frameColor either.
Unsetting the options did nothing, I still don't get anything besides thumbs.


h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2007-11-12 18:51

Hi H0bbel,

The xml url you posted above (http://sandbox.p0ggel.org/gallery2/main.php?g2_view=simpleviewersource.XMLOut&g2_itemId=65094) is currently giving this as the output:

<?xml version="1.0" encoding="UTF-8"?><simpleviewerGallery maxImageHeight='640' maxImageWidth='640' textColor='#ffffff' frameColor='#ffffff' frameWidth='640' stagePadding='5' navPosition='left' thumbnailColumns='3' thumbnailRows='3' title='moblog' thumbPath='http://sandbox.p0ggel.org/gallery2/main.php?g2_view=simpleviewersource.DownloadThumb&g2_itemId=' imagePath='http://sandbox.p0ggel.org/gallery2/main.php?g2_view=simpleviewersource.DownloadMax&g2_itemId=' >
<image><filename>65097</filename><caption>office.jpg</caption></image>
<image><filename>65101</filename><caption>xmaseve-cover.jpg</caption></image>
<image><filename>65103</filename><caption>Picture007.jpg</caption></image>
</simpleviewerGallery>

With textColour and frameColor set to #ffffff, and a frameWidth of 640. I don't think it's a bug in the simpleviewersource code as neither my installation nor Kirk's gets those parameters wrong. Can I ask you to double double check that you've not go those options set in any higher level album (such as the root) - and either way please try specifically setting the frameWidth to 40 in album id 65094, which should override the value of 640?

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Mon, 2007-11-12 20:14

Ah, I've changed which album i want it from since then :-) But, I found the error. While playing with this I also set some parameters for the root album, that was the values overriding the non-set parameters for the sub albums. After cleaning that up, it works fine!

My bad. ;-)


h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Mon, 2007-11-12 21:50
 
ckawalek

Joined: 2005-01-25
Posts: 104
Posted: Tue, 2007-11-13 06:48

I'm getting a security violation when I try to view the xml output:

http://christianjamesphoto.com/main.php?g2_view=simpleviewersource.XMLOut%26g2_itemId=31281

Quote:
Error Detail -
Error (ERROR_BAD_PARAMETER) : simpleviewersource.XMLOut&amp;g2_itemId=31281 can't be parsed

* in modules/core/classes/GalleryView.class at line 149 (GalleryCoreApi::error)
* in main.php at line 318 (GalleryView::loadView)
* in main.php at line 94
* in main.php at line 83

System Information
Gallery version 2.2.3
PHP version 5.2.3 apache2handler
Webserver Apache/2.2.4 (FreeBSD) mod_ssl/2.2.4 OpenSSL/0.9.7e-p1 DAV/2 PHP/5.2.3 with Suhosin-Patch
Database mysql 5.0.45
Toolkits ImageMagick, Thumbnail, Gd
Operating system FreeBSD freebsd3.visn.net 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12 11:05:30 UTC 2007

:/usr/obj/usr/src/sys/SMP i386
Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9

and simpleviewer doesn't show anything besides the title of the album:

http://christianjamesphoto.com/simpleviewer/index.html

are there directory permissions that are set wrong or something?

--
Chris
http://ChristianJamesPhoto.com

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2007-11-13 10:31

ckawlek:

To view the xml output in your browser you must "unescape" the %26 back to an & in the url, thus:

http://christianjamesphoto.com/main.php?g2_view=simpleviewersource.XMLOut&g2_itemId=31281

Ignore the "XML parsing error" - go directly to view page source on that link. You'll see that your gallery appears to be empty (no <image></image> tags in the xml) which is why only the title is showing. How many picture items do you have in that gallery? Are they regular photo items or link items, or something else? What happens if you point it at a different gallery?

Permissions should not be an issue: as a fallback you should see the thumbnails re-displayed as the main image if nothing else is available.

[edit] Actually that's not quite true: the browser running simpleviewer (either as a guest or a registered user) needs at least core.view permission on the items in the album that you want to display.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2007-11-13 11:38

This version should display original images with watermarks, if they are set.

ckawlek: see if this new version fixes your problem, too.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2007-11-13 15:06

*rse - now I've edited that post, it's moved to the bottom of the page. Is there any way to get it back to the top of the thread, where it makes sense?

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Tue, 2007-11-13 15:48

Alecmyers: No, I don't think we can move it. You could just make a new thread and put your release notes there. And, we should get some of the devs to look at this and possibly put it on gallery-contrib so people can download it via Downloadable Plugins.


h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2007-11-13 16:53
Quote:
Is there any way to get it back to the top of the thread, where it makes sense?

I think you should start a new thread and point this thread to that, as well as the codex.
Thanks for the contribution as well as keeping the codex updated.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
ckawalek

Joined: 2005-01-25
Posts: 104
Posted: Tue, 2007-11-13 17:08

The new version works perfectly! Thanks!
I also went back and set the chmod permissions for the simpleviewer module folder to 777 - that's where it's supposed to be, right?

alecmyers wrote:
This version should display original images with watermarks, if they are set.

ckawlek: see if this new version fixes your problem, too.

--
Chris
http://ChristianJamesPhoto.com

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2007-11-13 17:15

ckawalek:

Um... not sure. Mine appears to be on 755 (as do all the other modules in my installation) so I would go with that.

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Thu, 2007-11-15 20:46

Alec,

First, the latest version worked straight out of the box! Thanks.

I've been creating a sandbox for testing, so that it's not all on my laptop where I can't show someone what I'm talking about. Please look at http://sandbox.steffensenfamily.com/g2image/simpleviewer/

I have the max height and width set to 800 in the root gallery, but the sandbox page is downloading the fullsized images instead of the smaller resizes. I haven't looked at the code yet, but did you mean it to download resizes that are smaller than the max sizes? If so, I have some code in G2Image that I can paste for you to modify and include.

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-16 00:13

Hi Kirk,

Interesting point. Simpleviewer uses the maxHeight / maxWidth to down-scale the pictures, as long as enableImageDownScaling is set to true in the options (you have to have the source code to disable it) so it would make some sense to send only the next resize up from those dimensions. As things stand, simplviewersource (by design) sends the original if permissions allow - and if not, the first resize (and then falls back to the thumbnail if the user hasn't view permission on the resize.) By all means suggest some code - I confess that for my application the originals are all small enough to download very fast, so I haven't paid too much attention to this up till now.

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-16 04:15

Alec,

No worries. I've done that many times (made it work for my Gallery and then find out someone else uses it differently, like the whole watermarks thing...)

Since my camera takes great pics at 8 megapixels, I like to post them, but have multiple resizes. I rarely need the fullsizes, but the Gallery acts like an instant repository for the few times that I really want the full quality. Most of the time though, the resizes are more than enough, especially for web viewing instead of printing.

I'm almost done with the code. I have it getting the resizes, I just need to finish the logic about which specific resize is best. But I'm falling asleep. Will finish and post tomorrow.

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-16 12:48

Alec,

Here is the code for getting the original/resize that is the smallest, but still larger than the max sizes set in the options. This way, it will always be larger than the max so it will render well, but the smallest one of the group that is larger so that it will download more quickly.

I haven't thoroughly tested it with different permissions, etc.

It is running on my Gallery2/SimpleViewer sandbox, and it is definitely getting the resize instead of the original. Much faster.

I have the max height and width both set to 700. The sample gallery has the huge originals and resizes of 1024, 800, 640, and 320. If you look at the pictures downloaded by the following two links (as generated from the XML page), you can see that they are limited to 800 in height or width (as appropriate), which gives the next largest view above the limit of 700:
http://sandbox.steffensenfamily.com/gallery2/main.php?g2_view=simpleviewersource.DownloadMax&g2_itemId=24
http://sandbox.steffensenfamily.com/gallery2/main.php?g2_view=simpleviewersource.DownloadMax&g2_itemId=27

Now the only problem is that the settings appear to not being inherited correctly by child albums. The album in the sandbox is a child album off of root. I set the sizes in root, but the code I came up with didn't get the sizes. I got it to work in the sandbox by setting the sizes for that album. I expect that I made an error because I may not have fully understood how you have it set up. Something to look at either way.

EDIT: The links in this post do not show the behavior described any more. See the two posts below for code and link behavior changes.

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-16 14:24

Kirk,

You're getting the maxImageHeight & maxImageWidth settings by running another parameter query in DownloadMax on the parent album of the item being downloaded - but those settings might in fact be in a higher level album (as you found out) so you'd need to build the full parent tree and trawl for if/where those settings might be.

Better is to send the maxImageHeight and maxImageWidth as parameters back to DownloadMax by including them in the url which we built in XMLOut. That way the inheritance comes for free.

Try these two files - see if they accomplish the same thing (I think I've tested the corner cases, but I might have missed something).

The logic as to which image to select goes like this:

  • Build an array of all permissible derivatives, including the original and the thumbnail
  • Sort it by width (implicit assumption that all images have the same aspect ratio, but can't think of an exception that breaks badly)
  • Decide whether width-bound (true if maxImageHeight & maxImageWidth are taller and thinner than this image) or not
  • If so, send the first resize wider than maxImageWidth (if there is one)
  • If not, send the first resize taller than maxImageHeight (if there is one)
  • If maxImageHeight and maxImageWidth not set, or otherwise, send the largest (probably the original, but who knows)

If it works for you I'll roll them into a 0.2.5 edition.

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Fri, 2007-11-16 14:49

Alec,

Thanks! Your solution is more elegant. I'll probably steal some of your code for the same problem I've been working on solving.

A quick test shows it working in both height- and width-constrained cases:
http://sandbox.steffensenfamily.com/gallery2/main.php?g2_view=simpleviewersource.DownloadMax&g2_maxImageHeight=700&g2_maxImageWidth=700&g2_itemId=24
http://sandbox.steffensenfamily.com/gallery2/main.php?g2_view=simpleviewersource.DownloadMax&g2_maxImageHeight=700&g2_maxImageWidth=700&g2_itemId=27

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2007-11-16 15:16

Minor edits to previous files...

Change DownloadMax.inc at line 123 from:

$widthbound = ( $potentialImages[0]->height * $maxImageWidth < $potentialImages[0]->width * $maxImageHeight ) ? 1 : 0;

to:

	$widthbound = ( !$maxImageHeight || $potentialImages[0]->height * $maxImageWidth < $potentialImages[0]->width * $maxImageHeight ) ? 1 : 0;

for when $maxImageHeight is zero (i.e. unset)

Also change DownloadMax.inc at line 134 from:

if ( $maxImageHeight ) {

to:

elseif ( $maxImageHeight ) {

To avoid some unnecessary looking-for-sizes-that-don't-exist.

Glad you like the approach ;-)