PmGallery-Talk

« Return to pmGallery

Summary: Talk Page for pmGallery
Maintainer: DaveG
Categories: Images, Gallery, Picasa, Flickr

On using PmGallery with Authkey

3.14r, 8-Feb-2011: Hello,

I want to use PmGallery with some of my "protected" Picasa galleries. By "protected" I mean the galleries that are available for unauthenticated users, but via an URL with the authkey parameter. I encounter two problems:

  1. the cookbook shows nothing on the page of these galleries, even with the authkey parameter correctly set (in the markup or in the config file)
  2. the cookbook is enable to retreive the cover of these galleries because they do not appear in my public gallery feed

I did some empirical investigation on the first problem and it seems that it can simply be solved by not using the query parameter when there is no query. With the current schema used by PmGallery (that of the "api" namespace, and not the "base" one), adding "q=" in the URL returns nothing. To make sure that the query is not appended when it is not necessary, I just changed the line 54 of picasa.php5 into

	$feedUrl = (empty($album)	? '' : '/album'. (isset($isID) && $isID ? 'id' : ''). '/'. $album). '?kind=photo';
	$feedUrl .= (empty($this->options['query'])? '' : '&q='.$this->options['query']);

I agree that this is just a quick hack but it is not so ugly and produces a more semantically correct URL.

The second problem is worst since all PmGallery code is based on the assumption that all albums are in the public album feed, with the "mode" parameter used as switch between default, "linkdirect" and "cover" behaviours. To really support the "authkey" parameter and the "cover" mode, it will be necessary to go grab the feed of the album itself in order get the cover image. I think it is not that complicated but all the processing logic will have to be rewritten and I have no time right now.

But I have implemented a workaround by simply using the first image of an album as its cover. To generate an album list with those (pseudo-)covers, I use a pagelist like this:

(:pagelist group=Photos order=-ctime name=-GroupHeader,-GroupFooter,-RecentChanges,-Photos fmt=#galleries :)

[[#galleries]]
>> block lfloat <<
[[{=$FullName}|(:pmgallery user="{=$:user}" album="{=$:album}" authkey="{=$:authkey}" maxresults=1 wrapper="div > div" thumbsize=144 mode=nolink :)]]\\
''''+[[{=$FullName}|{=$Titlespaced} ]]+''''
>><<
[[#galleriesend]]

The parameters for "user", "album" and "authkey" are stored as PTV into the album pages. To grab the first image, the key parameter is of course "maxresults=1".

I had to introduce a new mode that I called "nolink" in order to be able to link towards the gallery and not to the the picture that I use for cover (linking to the picture is the default behaviour of PmGallery). To support the "nolink" mode, I modify PmGallery.php by simply wrapping the call to MakeLink like this:

...
	$noLink = $o['mode']=='nolink';
...
		if ( ($displayCover && in_array($gphoto['name'], $albums)) || !$displayCover) {
			$text .=
				'<'. $wrapper[1]. '>'.
				($noLink ?
					'<img src="'. $image['thumbSrc']. '" '.
					// unable to find h/w for album cover images
					($displayCover ? 
							''
						: 
							'height="'. (empty($o['height']) ? $entry['thumbnail_h'] : $o['height']). '"'.
						 	'width="'. (empty($o['width']) ? $entry['thumbnail_w'] : $o['width']). '"'
					).
					' />' 
				: 
					MakeLink(
					$GLOBALS['pagename'],
					($linkDirect
						? $image['largeSrc']
						: (preg_match('!(\.|\/)!', $o['wikitarget']) ? $o['wikitarget'] : $image_title[0])
					), //target
					'<img src="'. $image['thumbSrc']. '" '.
						// unable to find h/w for album cover images
						($displayCover ? ''
							: 'height="'. (empty($o['height']) ? $entry['thumbnail_h'] : $o['height']). '"'.
							  'width="'. (empty($o['width']) ? $entry['thumbnail_w'] : $o['width']). '"'
						).
						' />',	//link text
					'',		//suffix
					'<a class="pmGallery'. ($displayCover ? 'Album' : 'Image'). 'Thumb" '.
						"href='\$LinkUrl".
							// add optional parameters onto the end of the link url ( &album )
							($linkDirect ? ''
								: ($displayCover
										? '?album='. htmlentities($gphoto['name'])
										: '?imageurl='. htmlentities(str_replace('http://', '', $image['largeSrc']))
									)
							).
						"' ".
						(empty($entry['description'])
							? ''
							: 'title="'. htmlentities($entry['description'])
//								. (empty($o['exif']) ? '' : 'EXP: ' .$exif['exposure'])
								. '"').
						">\$LinkText".
					'</a>'
					)
				).
				'</'. $wrapper[1]. ">\n";
		}
...

Now, I agree that this is an ugly hack, but I'm not a PHP programmer and right now that's all I have the time to do :-). While we are waiting for a real fix, I just hope that it can be useful for somebody.

What do you think ?

Thanks for PmGallery !

Using this together with Mini or ThumbList?

Jonas, 16-Jun-2009: Hello, I've been using Mini and ThumbList for quite a while, but have always been looking for a way to connect it with Flickr or Picasa. Is there any chance of making the Picasa API work together with Mini or ThumbList? Thanks!

DaveG, 16-Jun-2009: I'm not quite sure what you'd be trying to achieve, as PmGallery and Mini/ThumbList seem to be doing different things. Mini/ThumbList provide a means of generating thumbnail images from larger images; there's no need to do that if the images are stored at Picasa.

file_get_contents failed to open stream

I'm consistently getting this error message, only when I access an album for the first time

Warning: file_get_contents(http://picasaweb.google.com/data/feed/api/user/USER?kind=album&max-results=50&start-index=1&thumbsize=72&q=)\\
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in \\
/pmWiki/cookbook/pmgallery/feeder.php on line 51

(where USER is set to a Picasa user name). Then if I reload the page in my browser (Opera10) everything works fine again.

update: given the above URL directly, Picasa returns:

  Query parameter not allowed for album kinds.

SteP

1-Jun-2009, DaveG: Logged as a bug. Looks like Google has made some changes to their API. A few other bugs have suddenly appeared as well. Fixed in version 0.3.1.

Question 0718-2008 20:00 GMT+1

Hi,

I'd really like to make the pmGallery work on my website, but so far I get the following error message whenever I use the pmGallery markup:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION 
or T_FUNCTION or T_VAR or '}' in /home/damhaugc/www/bryllup/cookbook/pmgallery/picasa.php5 on line 14

I have tried my best to follow the recipe, but obviously something is wrong. As my skill wih PHP is fairly limited, I can't identify the problem. The PHP5 prerequisite mentioned may be it, but I don't know how to check for this. Any suggestions?

My site is using the following version and recipes from pmWiki:

pmwiki-2.2.0-beta65 (Is the new beta67 required?)

Update to question 0718-2008 20:00 GMT+1

I went to my ISP and upgraded from PHP 4.4.4 to PHP 5.1.5, and suddenly it all started working :-) Problem solved, in other words. Thank you for a great recipe!

Solution: 19-July-08 13:36 EST by DaveG'''

pmGallery requires PHP5. Thanks for testing!

Question 0718-2008 22:30 GMT+1

On the example site http://wiki.solidgone.org/PmGallery/Demo, thumbnails display perfectly, but the gallery does not open correctly when clicking a thumbnail.

Error message is the usual "The web page can not be found" (HTTP 404)

I also have the same problem when using pmgallery on my own site. Any quick fixes?

Update to question 0718-2008 22:30 GMT+1

After some experimenting, I came to the conclusion that the error displays because the empty wikipage with name [[InsertPmGalleryGroupName/InsertImageFileName]] is not automagically created as you click a thumbnail. It is a little strange that this happens also in the example site, and not only on my site. If someone finds out what is missing, please give me a hint.

Update 2 to question 0718-2008 22:30 GMT+1

Workaround from original poster (this is not a solution to the error):

in (:pmgallery:) markup, use the wikitarget=yourGroup.yourPage to specify the page in which pictures are opened. Remeber to manually create the specified yourGroup.yourPage (it can a be empty page, but it must be created). Also, for me this workaround needs $EnablePathInfo = 0 in config.php

Solution: 19-July-08 13:36 EST by DaveG

Thanks for letting me know. I've fixed this problem with the latest v0.1.3, available for download.

Fatal Error again - The 6 of January of 2009

I've got the following error:

Fatal error: Call to a member function getDocNamespaces() on a non-object in /var/www/ranar.open-web.fr/www/galerie/cookbook/pmgallery/picasa.php5 on line 93

I'm using PHP 5 with all activated functions. What's happen ?

Thanks, Didier

Response 6-Jan-2009 10:37 EST

  1. What parameters are you passing?
  2. What happens when you replace the word USERNAME in the URL below with the user you're actually using? [(approve links) edit diff]

Now it's working well. I think it was an error because of my hosting service. Thanks for your rapid answer.

Response 12-Mar-2009 12:51 EST cba

FIX for "Fatal error: Call to a member function getDocNamespaces() on a non-object in cookbook/pmgallery/picasa.php5 on line 93"

   // parse the RSS Feed -- needs PHP5
   $feedXml = str_replace('>', ">\n", $feedXml);
   $feed = simplexml_load_string($feedXml);

   if ($feed == false)
      {
      return;
      }

   $namespace = $feed->getDocNamespaces();
   $feed_arr = array(); //Array that contains all loaded and parsed Data

   //Main user information

Response 12-Mar-2009 19:45 EST

Fix is now available from version 0.3.0. Thanks.

Remark 0725-2008 21:00 GMT+1

I've been playing around a little with the thumbsize parameter, and found the following:

thumbsize = 72, 144, 288, 576

Works fine

thumbsize = 32, 48, 64, 160, 200, 320, 400, 512, 640, 720, 800

Gives thumbs that are stretched to square shape, that is wrong aspect ratio unless the image is square to begin with. The thumbs also have poor display quality for these sizes.

DaveG 26-Jul-2008 22:40

Thanks for the info. I just re-checked Googles API page and it seems that there are some restrictions on thumbsize. However, they don't match your findings. I'll take a look and see what's happening -- I suspect it's something to do with the cropping. For those interested this quote is from the Google API:

The following values are valid for the thumbsize and imgmax query parameters and are embeddable on a webpage. These images are available as both cropped(c) and uncropped(u) sizes by appending c or u to the size. As an example, to retrieve a 72 pixel image that is cropped, you would specify 72c, while to retrieve the uncropped image, you would specify 72u for the thumbsize or imgmax query parameter values.

32, 48, 64, 72, 144, 160

The following values are valid for the thumbsize and imgmax query parameters and are embeddable on a webpage. These images are available as only uncropped(u) sizes by appending u to the size or just passing the size value without appending anything.

200, 288, 320, 400, 512, 576, 640, 720, 800

Fatal error

I am getting following error while testing code from solidgone sandbox

(:pmgallery imagesize=512 user=nepherim album=Quiddity mode=linkdirect wrapper=ul>li:)
(:div id="pmGallery_Image":)
(:divend:)
(:galleria list=".pmGalleryWrapper ul" image="#pmGallery_Image" carousel=true:)

Fatal error: Call to a member function getDocNamespaces() on a non-object in /home/savevill/public_html/cookbook/pmgallery/picasa.php5 on line 93
Vikas

Galleria is not working

I was trying pmgallery and galleria recipes on my site but it seems galleria is not working with carousel. I did following changes in config.php

$pmGallery['virtualgroups'] = array('+Bihar');
$pmGallery['user'] = 'vikas.kum';
include_once("$FarmD/cookbook/pmgallery/pmgallery.php");
include_once("$FarmD/cookbook/galleria/galleria.php");

And following code on test page

(:pmgallery imagesize=512 user=vikas.kum album=Bihar mode=linkdirect wrapper=ul>li:)
(:div id="pmGallery_Image":)
(:divend:)
(:galleria list=".pmGalleryWrapper ul" image="#pmGallery_Image" carousel=true:)

I tried same code in solidgone sandbox and it is working. On my test page picture is getting displayed so pmGallery is working but galleria is not doing its job. I am doing something wrong but don't know where?

vikas

Question 0727-2008 22:30 GMT+1

I've been using pmgallery and galleria recipes for a few days now, and only one issue remains before perfect functionality is achieved :-). I am not able to get the wrapper="ul > li" parameter to cooperate with galleria parameters list=".pmGalleryWrapper ul" and carousel=true.

What I get when I try that, is basically an empty carousel. It is rather strange, since both galleria and pmgallery seems to work properly on my site. It seems to be connected to the magical ul word, or maybe the wrapper="ul > li" parameter for pmgallery. Is it any way to verify that pmgallery gets it correctly, regarding wrapper="ul > li"? For me, pmwiki on my site is no longer displaying the thumbs as a bullet list, when I use wrapper="ul > li". That is a bad sign, right?

What I'm trying, that is not working, is the following:

(:pmgallery imagesize=512 user=nepherim album=Quiddity mode="linkdirect" wrapper="ul > li":)
(:div id="pmGallery_Image":)
(:divend:)
(:galleria list=".pmGalleryWrapper ul" image="#pmGallery_Image" carousel=true:)

For a working solution with no carousel, I use the following parameters:

(:pmgallery imagesize=512 user=nepherim album=Quiddity mode="linkdirect" wrapper="li":)
(:div id="pmGallery_Image":)
(:divend:)
(:galleria list=".pmGalleryWrapper" image="#pmGallery_Image" :)

If anyone see what I'm doing wrong in the first code example, please give me a hint.

(I swapped user and album parameters, just to keep focus on my technical troubles instead of my wedding pictures:-))

Response 28-Jul-2008 11:10 EST

Are you using the exact code above, and things are not working? It sounds like you are actually using different parameters (for your wedding pictures) -- it would be helpful to see exactly what you have. If you can provide a URL, I can take a look and see what's up -- if you'd rather not post it here, send it to me in an email to ikiwmp at solidgone dot com (reverse the first word to form the name of a well known wiki :)

  1. The second block of code might work, but isn't going to form valid html, so it's a the mercy of the browser. Try using "ul>li" instead of "ul > li" (ie, no spaces) -- that shouldn't make a difference, but who knows.
  2. If you are using the first block above (with nepherim as the user) then things looks right. However, you mention that you don't see the list. That seems to suggest that Galleria is kicking in and replacing the list with the elements it needs. Are you sure you have downloaded the Cookbook directory and the Galleria directory in the Pub directory of your PmWiki install?
  3. You might want to check the source of your page, copy the galleria css path and paste it into the browser address bar to make sure it's available.

Talk page for the pmGallery recipe (users).