RSS vs. ImageBlock for Wordpress Sidebar Images

ginakra

Joined: 2003-03-13
Posts: 9
Posted: Wed, 2007-01-24 20:32

Hi all,

I have Gallery 2.1.2 and I'm confused on how to display images from my Gallery in my Wordpress sidebar. I've been looking at ImageBlocks, but I can't figure out how to target a specific album. Should I use RSS instead?

I have these albums:
---------------------------
Album: Completed Projects
Sub-album: 2006
Sub-album: 2007

Album: Current Projects

Album: Future Projects
---------------------------
Ok, I want to display in seperate imageblocks (or by feed) on my wordpress blog sidebar:

1. A random image from the Completed Projects and all the subalbums underneath as a whole.
2. The most recent image from Completed Projects, subalbum "2007" only.
3. A random image from Future Projects
4. A randome image from Current Projects.

I've tried:
http://www.mysite.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title

but it shows a random image from ALL the albums and subalbums. How do I target specific albums? Or, should I use RSS for what I want?

Thanks for any help. I just installed Gallery yesterday, and have done a lot of reading, but I'm kind of stuck here.

Gina

 
ginakra

Joined: 2003-03-13
Posts: 9
Posted: Wed, 2007-01-24 22:38

Well, it figures after working on it all day yesterday and most of the day today, I find the answer myself not long after I post, lol. In order to help someone else who has the same question, here's how I did what I wanted.

You can target specific albums in an external imageblock. All you have to do is find the itemId of the album you want to pull images from. You find the itemId by clicking on the album you are going to target and looking at the url. You should see itemId=xx in the url. If you don't, try turning off URL Rewrite (Admin-->URL Rewrite). Just uncheck anything that is acitvated (write them down first so you can reactivate later) and save the changes, then reload your gallery.

Once you have the itemId, then you can just plug it into the external imageblock code and away you go. For example, I wanted to pull:

2. The most recent image from Completed Projects, subalbum "2007" only. The itemID of "2007" is "60" so the code would be:
<?php @readfile('http://www.site.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=recentImage&g2_itemId=60&g2_show=title'); ?>

3. A random image from Future Projects. The itemId of "Future projects" album is "61", so the code is:
<?php @readfile('http://www.site.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_itemId=61&g2_show=title'); ?>

(obviously, make sure your site url path is correct, replacing your gallery url with the one the imageblock area says you should). I found the answer during a web search. Between this Drupal page http://drupal.org/node/53087, and this forum page http://gallery.menalto.com/node/53803, I got it working.

Hope this helps someone else!
Gina

 
quixote
quixote's picture

Joined: 2007-02-05
Posts: 22
Posted: Wed, 2007-02-07 22:58

Gina, thanks for coming back to say how to solve the problem! This is exactly what I was looking for, but unlike you, I'd never have figured it out on my own. (If and) when I have it working, I'll come back to report success (or failure).

 
quixote
quixote's picture

Joined: 2007-02-05
Posts: 22
Posted: Sat, 2007-02-10 21:36

Nope, my hosting service doesn't allow readfile to work for security reasons, so I had to go to this method: How_To_Use_The_External_Image_Block_When_url_fopen_Is_Disabled

Briefly, that requires the following code:

Quote:
<?php
$ch = curl_init();
$timeout = 5; // set to zero for no timeout MY NOTE: YOU DEFINITELT WANT THIS AT 0!
curl_setopt ($ch, CURLOPT_URL, 'http://www.example.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>

with one's own URL inserted. Set show=none at the end of the long line if you don't want the titles appearing. The images appear at whatever size the thumbnail is set at in Gallery2. I wanted to control thumbnail size, so I ended up using the WPG2 plugin, after all.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2007-02-10 23:16