Flickr Gallery 0.5
November 23rd, 2004This project is now closed. Please use the much superior FAlbum if you want to integrate Wordpress and Flickr.
Update (1/8/2005) - A new version is available here with some of the features requested in this post’s comments and also some bug fixes.
This is an update to my Flickr gallery plugin with a couple new features and some bug fixes. Some of the salient features include:
- Flickr photosets as “albums” - complete with descriptions and meta
- Support for Flickr “notes” feature - just this plugin uses all CSS and Javascript instead of Flash (the plugin’s output looks like this)
- EXIF data support to display camera settings the photo was snapped with — in addition to the description and meta info from Flickr
- Valid XHTML output
- * new * Option to respect photos marked “private”
- * new * Thumbnail size choices
You can download it in .tar.gz format here or .zip format here.
An example installation can be found here. Read on for installation instructions.
Installation Instructions:
- Make sure you have your Flickr photos organized into photosets.
- Extract the files somewhere.
- Edit flickr-gallery.php with your settings.
- Set FLICKR_USER_ROOT constant to your Flickr page (something like http://www.flickr.com/photos/username/ - it’s your Flickr “alias”) so that the plugin can build the comments links for your photos.
- Set FLICKR_EMAIL constant to your Flickr account login (the email address you signed up with)
- Set FLICKR_PASSWORD constant to your Flickr account password
- Set FLICKR_CACHE_PATH constant to the path of your cache directory (something like /var/www/localhost/wp-content/flickr-cache/). This directory should be in your WP-content directory and must be writable by the web server/PHP.
- Optional - Set FLICKR_CACHE_EXPIRE to the number of seconds you want the cache to live for. 600 secs (10 mins) is suggested so as to not overload Flickr with API traffic and get your IP address banned.
- Set FLICKR_THUMBNAIL_SIZE constant to the size you want your thumbnails to appear as (’s’ = 75px x 75px, ‘t’ = 100px x 75px, ‘m’ = 240px x 180px)
- Set FLICKR_SHOW_PRIVATE constant to false if you want to respect photos marked as private in Flickr
Do not change the API key. Also, PLEASE do not steal the API key. This one has been assigned to this plugin and Flickr uses it to track API usage. You can get your own API key here for your own projects or derivatives of this code.
- Put flickr-gallery.php in your WP-content/plugins/ directory and activate the plugin via your WP admin console.
- Copy your index.php file to gallery.php (or another filename if you want). Edit gallery.php by replacing everything inside
<div id="content"> ... </div>
with
<?php flickr_show_photos($_GET['album'], $_GET['photo']); ?>
Make sure you still have <div id=”content”>. Then create links to gallery.php from wherever you want to link to it.
- Define the flickr-album, flickr-thumbnail, flickr-photo, flickr-title, and maybe flickr-description style
classes in your style sheet. Modify the classes to fit the look and
feel of your site. My classes look like this:.flickr-album { padding: 0; width: 550px; clear:both; } .flickr-thumbnail { float:left; padding-right: 20px; background-color: #fff; border: 1px solid #a9a9a9; margin: 6px 6px 6px 6px; padding: 4px; margin-top:10px; } .flickr-photo { padding-right: 20px; background-color: #fff; border: 1px solid #a9a9a9; margin: 6px 6px 6px 6px; padding: 4px; margin-top:10px; } .flickr-title { width: 500px; color: #260; padding-top: 6px; } - If you want to use the Flickr “notes” part of the plugin you must do the following:
- Put annimg.js somewhere (I put it in my blog root).
- Add
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/annimg.js"> </script>to your gallery.php head.
- Define the a.annotation, a.annotation span, and a.annotation:hover styles in your style sheet. My classes look like this:
a.annotation { position: absolute; border: 1px solid white; padding: 0; display: none; } a.annotation span { display: block; width: 100%; height: 100%; /* Setup translucent background in notes box with browser specific opacity * properties (they aren't valid CSS - sorry). If having valid CSS is * so important to you just get rid of the next 4 lines after these * comments (you'll sacrifice the translucent background in the notes * boxes though). */ background: white; opacity: 0.2; -moz-opacity: 0.2; filter: alpha(opacity=20); } a.annotation:hover { border-color: yellow; }
System Requirements:
PHP 4.1 or greater - with allow_url_fopen enabled (to make remote API/REST calls and download images)
Wordpress isn’t actually required because this doesn’t use any of WP’s plugin hooks
Of course this code comes with no guarantee. If you need support I’ll be glad to help (within reason) — just shoot me an email. If you want to suggest future features or just tell me that you are using my plugin I’d appreciate that feedback too.
Copyright (c) 2004
Released under the GPL license
November 23rd, 2004 at 11/23/2004 7:17 am
I just installed your marvellous plugin on my blog. Thank you - it’s fairly easy to install, works great and looks good with little or no hassle.
I have one “issue” with it, though. Since the rest of my blog is in Swedish I would really like my gallery to be in Swedish as well. It looks kind of stupid with English text interleaved between my titles and descriptions in Swedish.
I would be willing to translate the few bits of text, but where do I put the translations? The text is probably hardcoded in the PHP file at the moment. Do you intend to move it out of there or should I just make a Swedish version of the file?
November 23rd, 2004 at 11/23/2004 7:47 am
Basse,
Localization is something I haven’t thought of yet. Yes, the text is hardcoded in the PHP. It is probably easiest for you to simply make a Swedish version of the file.
Your question got me looking at WP localization features though, and for future versions of my plugins I think I am going to try to use gettext for translation. That would allow users to use the already translated dictionaries. On the other hand, I doesn’t look like it is quite as simple as flipping a switch to change languages.
Ray
November 23rd, 2004 at 11/23/2004 7:58 am
[...] saker och ting fort framåt. En dag efter att jag upptäckte Flickr hittade jag en galleriplugin för Wordpress, som jag förstås genast installera [...]
November 23rd, 2004 at 11/23/2004 7:59 am
Flickrgalleri på basseblog
Ibland gÃ¥r saker och ting fort framÃ¥t. En dag efter att jag upptäckte Flickr hittade jag en “galleriplugin”:http://www.worrad.com/archives/2004/11/23/flickr-gallery-WP-plugin/ för Wordpress, som jag förstÃ¥s genast installerade pÃ¥ prov. Det fun…
November 23rd, 2004 at 11/23/2004 8:03 am
Sorry for the “comment spam”, I didn’t remember to turn off Pingback for all URIs when posting. BTW, if you’re wondering - the strange characters are UTF8-coded umlauts.
November 23rd, 2004 at 11/23/2004 2:24 pm
this looks like a terrific implementation .. i am looking forward to playing around with it soon.
the best thing is that it doesn’t require wordpress.
one thing that would be very useful to me would be the ability to list all of my {or someone else’s} images on a single page, in thumbnail. it makes for much easier image image browsing at a glance, in my opinion. like when you first meet a new contact and want to check out their previous work at a glance.
November 23rd, 2004 at 11/23/2004 4:10 pm
Fantastic work! An easy-to-use and elegant solution. Thanks for sharing this — it’s _exactly_ what I’ve been looking for!
November 24th, 2004 at 11/24/2004 1:32 am
One thing that someone brought up on my site is that large galleries take a long time to load. I think pagination would be a valuable feature to implement.
November 24th, 2004 at 11/24/2004 4:18 am
Nice plugin. My provider disabled URL file access, so I can’t use it - but it’s a good idea anyway.
November 24th, 2004 at 11/24/2004 11:13 am
A nice plugin!
And I just wonder how you post the source code with indentation in WP….could you mind to telll me how?
November 24th, 2004 at 11/24/2004 12:06 pm
Aaron,
I just stick the code in
<pre> ... </pre>tags. That keeps the original whitespace and everything (and allows users to copy and paste it without getting a bunch of markup junk). It might be more semantically correct to put it in<code> ... </code>tags, but I find my way works better if you want to copy and paste the code into something.Ray
November 24th, 2004 at 11/24/2004 9:32 pm
Using
codefor a one-line snippet and usingprefor a block is a widely-accepted practice… I don’t think there is a semantical problem.So how about pagination? You think that’s doable?
November 25th, 2004 at 11/25/2004 1:00 am
Mark J,
I do think pagination is doable, but I won’t have time to work on it until this weekend. I’ll let you know what I come up with.
Ray
November 25th, 2004 at 11/25/2004 3:11 pm
Hello!
Is it possible, that this plugin doesn’t work with wordpress alpha versions 1.3? Tried it out a couple of minutes ago and got only a PHP error in line 57 of flickr-gallery.php?
November 26th, 2004 at 11/26/2004 4:07 am
Coolio Flickr apps
Here’s the latest from Eric Costello…. One of the things I love about Flickr is its openness. We are open as a company, participating in discussions with our members on public message boards about our future plans, our (ever dwindling list of) bugs,…
November 26th, 2004 at 11/26/2004 9:37 pm
Works like a charm for me on Wordpress 1.3a. This is a great tool; thanks for hooking it up!
November 27th, 2004 at 11/27/2004 1:49 am
[...] nks,” you’ll see a link to my nice new Flickr Gallery :D. Many many thanks to Ramon Darrow for the plugin :). I know it’s not a very good place for [...]
November 27th, 2004 at 11/27/2004 11:07 am
I was having trouble finding your email, sir. I was hoping you would help me with flickr plugin.
http://www.franklinfamily.org/gallery.php
-jayson
November 27th, 2004 at 11/27/2004 12:28 pm
If you see here:
http://www.officialsm.net/test/wordpress/wordpress/gallery.php
you can see the problem in the page.
The tag < ?php flickr_show_photos($_GET['album'], $_GET['photo']); ?>
is write without space,
Anyone help me, with some idea?
Thank you
November 27th, 2004 at 11/27/2004 2:35 pm
Having some config issues…
Warning: fopen(/var/www/localhost/htdocs/weblog/wp-content/flickr-cache//http%3A%2F%2Fwww.flickr.com%2Fservices%2Frest%2F%3Fmethod%3Dflickr.photosets.getList%26api_key%3D3a4570b7e7e2aaf6be97a55b07e89db5%26email%3Ddantrevino%40gmail.com%26password%3Dinsmodppa.cached): failed to open stream: Permission denied in /var/www/localhost/htdocs/weblog/wp-content/plugins/flickr-gallery.php on line 340
Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/localhost/htdocs/weblog/wp-content/plugins/flickr-gallery.php on line 343
Warning: fclose(): supplied argument is not a valid stream resource in /var/www/localhost/htdocs/weblog/wp-content/plugins/flickr-gallery.php on line 345
Warning: file_get_contents(/var/www/localhost/htdocs/weblog/wp-content/flickr-cache//http%3A%2F%2Fwww.flickr.com%2Fservices%2Frest%2F%3Fmethod%3Dflickr.photosets.getList%26api_key%3D3a4570b7e7e2aaf6be97a55b07e89db5%26email%3Ddantrevino%40gmail.com%26password%3Dinsmodppa.cached): failed to open stream: Permission denied in /var/www/localhost/htdocs/weblog/wp-content/plugins/flickr-gallery.php on line 349
An error occurred. Here is the response from Flickr:
And here is the response after passing through the parser:
array (
)
flickr-cache is 666 and owned by apache user
line 340 is:
$f2 = fopen($cache_filename,"w+"); // Open local cache file
and
FLICKR_CACHE_PATH='my path.../weblog/wp-content/flickr-cache/'
Anny ideas?
November 27th, 2004 at 11/27/2004 9:53 pm
so…fixed my previous error by ‘chmod 777 flickr-cache’ … doh! … also note, the password in the URL above is fake, my real password DID include some special characters, but the plugin does not work with my ‘real’ password. A bug in flickr.photosets.getList ????
November 29th, 2004 at 11/29/2004 12:30 am
[...] Flickr Gallery
Filed under: 技巧.j — kDolphin @ 1:33 pm
  Flickr Gallery这个æ’ä»¶å¯ä»¥æŠŠä½ çš„Flickr相册整åˆåˆ°ä½ çš„WP Blogä¸ [...]
November 29th, 2004 at 11/29/2004 4:11 am
Here is my error:
Parse error: parse error, unexpected T_ENDFOREACH in /home/clark/www.wvofuels.com/gallery.php on line 14Any ideas?
I love what you have done with the slide show right in the content of WP. I also especially like the thumbnails. Since I can’t experiment with it, are those feature that are pre coded or extra fancies that you’ve done for just your blog?
November 29th, 2004 at 11/29/2004 7:21 am
Clark,
Why don’t you send me a copy of your gallery.php to rdarrow at worrad DOT com. It looks like you have some bits of the the WP loop hanging around that shouldn’t be there. I’d be glad to help you out.
Ray
November 29th, 2004 at 11/29/2004 9:24 pm
I’ve been trying to get this plugin to work for a few days now with no luck.
This is the error I get:
Fatal error: Call to undefined function: flickr_show_photos() in /path/to/my/wp/installation/gallery.php on line 34
Any ideas why it keeps bombing?
Here’s a link to see it
Thanks,
Fil
November 30th, 2004 at 11/30/2004 5:07 am
I´m very happy to find this plugins, but I cann´t run because this APIKey I don´t know it.
It´s need API/key?
Excuse me because my english is very bad, bye.
November 30th, 2004 at 11/30/2004 6:30 am
pLog è·Ÿ Flickr 的完美çµåˆ
Flickr 是最近很æµè¡Œçš„社會型網路的相簿æœå‹™æœå¹³å°ï¼Œå°¤å…¶æ˜¯åœ¨ Schee 的大力推薦下幾乎 Blog 圈ä¸äººæ‰‹ä¸€å€‹å¸³è™Ÿï¼Schee 真的把 Flickr 講得é
November 30th, 2004 at 11/30/2004 9:07 am
Cinefilo,
You do not need to change the API Key in order to get the plugin to work. In fact, it is the one thing you should not change. Also, you should probably use the latest version (0.6).
Ray
December 3rd, 2004 at 12/3/2004 11:04 am
Very impressive plugin. Good that you can now respect photos marked Private in Flickr. However, Flickr lets you define various levels of privacy: Friends, Family etc. Most of my Flickr photos are not public, but my weblog is, so I don’t want to display all my Flickr images there.
Instead of hard-coding my user ID and password and passing it through the Flickr API, could you include fields for Flickr login in gallery.php? That way, friends and family coming to my blog could enter their login information on that page first, and that user ID/PW would be saved in variables and then passed to Flickr through the API (instead of my hard-coded info).
December 3rd, 2004 at 12/3/2004 5:38 pm
I’m having similar problems to a previous commenter:
file_get_contents(/home/.heathcote/schwa23/uncleleron.com/wp/wp-content/flickr-cache//http%3A%2F%2Fwww.flickr.com%2Fservices%2Frest%2F%3Fmethod%3Dflickr.photosets.getList%26api_key%3D3a4570b7e7e2aaf6be97a55b07e89db5%26email%3Dxxx%40uncleleron.com%26password%3Dxxxxxx.cached): failed to open stream: No such file or directory in /home/.heathcote/schwa23/uncleleron.com/wp/wp-content/plugins/flickr-gallery.php on line 390An error occurred. Here is the response from Flickr:And here is the response after passing through the parser:array (
)
Not sure if it’s because my host doesn’t enable allow_url_fopen or what — any suggestions?
oh, and I xxxedout my email and password in the code above.
December 3rd, 2004 at 12/3/2004 6:34 pm
Mark,
The different levels of privacy are surely something you could add support for if you want. Unfortunately, forcing the user to have to login with their own Flickr id is a little bit of a hinderance for usability. If your users are required to already have a Flickr id to view your photos you may as well require them to view them inside Flickr.
I think are on the right track for how to implement your idea though. The list of photos is based on what userid the request is made from, so you would have to get the user’s id and password they registered with Flickr with (and requires that your users trust you not to abuse the knowledge of their id and password). The challenge of course is that you have to then store the id and password in something that is going to last longer than a single page load, namely a cookie or a session, otherwise your users will have to login again for every request they make. That adds a whole new level of complexity to the script that I didn’t really want to get into.
Feel free to hack it yourself though. It was released under the GPL so derivatives and branches are allowed and even encouraged. I know one user is already working on a version that will show the entire Flickr photostream instead of requiring that photos be organized into photosets. So, have at it and add all the features you want.
Ray
December 3rd, 2004 at 12/3/2004 6:52 pm
Josh,
This could probably be due to one of two problems:
1. allow_url_fopen could be disabled. Make a new .php file and just put the following in it:
<?phpphpinfo();
?>
This will show you all your PHP settings. Just search for allow_url_fopen. It must be set to “On” for the script to work. Of course there is probably a way around it by writing a hack to connect to Flickr through a socket connection, but that would be up to you to write. The easiest way would be just to get allow_url_fopen turned on.
2. flickr-cache could have the wrong permissions set. It must be writable by the webserver. Most people just set their permissions to 777 (which is pretty permiscuous, but it is definitely writable by the webserver).
Also, you should probably be running version 0.6 of the plugin. It fixes a potential security risk.
Ray
December 9th, 2004 at 12/9/2004 2:16 pm
I installed it. but How can I use this plugin.
I have error :::
http://www.all-iran.info/home/gallery.php
———————————
An error occurred. Here is the response from Flickr:
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="fail">
<err code="1" msg="User not found" />
</err></rsp>
And here is the response after passing through the parser:
array (
'rsp' =>
array (
'err' =>
array (
'code' => '1',
'msg' => 'User not found',
),
),
)
problem..?
December 9th, 2004 at 12/9/2004 9:28 pm
seongeunlee,
That error means you aren’t logging into Flickr successfully. Double check the email and password you signed up for Flickr with.
Ray
December 12th, 2004 at 12/12/2004 6:14 pm
Warning: exif_read_data(1947315_d808e6626f_o.jpg): file not supported in /home/matt/public_html/wp-content/plugins/flickr-gallery.php on line 260
Any idea what I’m missing that could be causing that error?
December 12th, 2004 at 12/12/2004 7:13 pm
Hmm… I’m getting “Fatal error: Call to undefined function: flickr_show_photos() in /home/lasnik/public_html/photography/flickr/testy.htm on line 1″
I don’t use WP, so I just put “< ?php flickr_show_photos($_GET['album'], $_GET['photo']); ?>” into a test.php file and accessed that via my browser.
I assume I’m missing something really obvious here?
December 12th, 2004 at 12/12/2004 7:54 pm
Okay, I’m a dodobrain… I had overlooked that my server couldn’t automatically guess where the gallery script was. So I realized I have to load the script directly or include it somehow. Duh.
December 12th, 2004 at 12/12/2004 10:31 pm
Matt,
The
exif_read_data()error you are getting would seem to be because your installation of PHP doesn’t support the EXIF functions. You could always look at the output of yourphpinfo()function to see whether EXIF is turned on in your installation of PHP. You could also simply comment out line 260 and skip the EXIF functions altogether.Ray
December 13th, 2004 at 12/13/2004 7:15 pm
Here’s the output from phpinfo()
EXIF Support enabledEXIF Version 1.4 $Id: exif.c,v 1.118.2.27 2003/12/17 09:08:37 helly Exp $
Supported EXIF Version 0220
Supported filetypes JPEG,TIFF
I commented out the line and got things more or less working. It still displays the information regarding shutter speed, flash, etc. What does that one line control?
December 26th, 2004 at 12/26/2004 9:06 pm
[...] I’ve added a new feature to my blog today. I’m now using a plugin called Flickr Gallery which allows me to link up my Flickr photos to my blog. I̵ [...]
September 18th, 2005 at 9/18/2005 4:48 am
[...] Iba a escribir sobre un plugin para WordPress, el flickr-gallery-0.5, que te permite hacer un álbum fotográfico en tu propia página usando las fotos que tienes alojadas en flickr (aunque por lo que dice su autor no necesitas ni el WordPress), pero ya que me pongo a hablar de flickr, contemos algunas cosas más. [...]
September 28th, 2005 at 9/28/2005 1:48 am
[...] http://www.worrad.com/archives/2004/11/23/flickr-gallery-WP-plugin/ [...]