Posts Tagged ‘FlickrRSS’

Making FlickrRSS Work for Me

Posted on:

My goal with this new site is to not only to design a very clean, beau­ti­ful site, but to also show­case some of the nice effects that are pos­si­ble with javascript libraries like jQuery (and teach myself how to effec­tively use them in the process). Last night, I worked for over 6 hours sim­ply get­ting one small sec­tion of the front page to work the way that I want it to. My rule for myself was sim­ple: I would accept no com­pro­mise from the design that I drew in Photoshop–unless IE 6 and its crappy ren­der­ing forced me to, which it did on the hor­i­zon­tal tab nav­i­ga­tion. Bad browser! BAD! No biscuit.

So, if it’s still work­ing, you should see a big image from flickr. You hover over that image, and you should see the image title and the descrip­tion from flickr slide up onto the image, and if you mouse-​​off, the details will float back down.

The ani­ma­tion and hover effect is cre­ated with jQuery and a plu­gin for jQuery called hov­er­In­tent. I had to add hov­er­In­tent because I wanted a delay between mou­s­ing off the image and the slide-​​down. Doing this part, includ­ing writ­ing the CSS and javascript, was actu­ally only about an hour’s worth of cod­ing at the most, and the only rea­son it took that long was because I screwed up includ­ing the script, and then I wanted that delay and had to go find out how to do that with hoverIntent.

Where things really got sticky was fig­ur­ing out how to get the data from Flickr onto my page.

Here’s why: there are basi­cally two plu­g­ins that you can use with WordPress to talk to Flickr. Unfortunately, nei­ther one did exactly what I wanted. After play­ing with Falbum and FlickrRSS, I decided FlickrRSS was going to be the eas­i­est for me to beat into sub­mis­sion. Important caveat: WordPress runs on PHP. I’ve worked with PHP off and on for the last 8 years, but I have never really learned it. I am NOT a programmer–I am a designer. A pro­gram­mer prob­a­bly could have writ­ten the code to do what I wanted to do here in about an hour. If a client had asked me to do this kind of mod­i­fi­ca­tion, I would have con­tracted out the work to an expert. But I’m cheap and I took it as a learn­ing oppor­tu­nity, so I beat my head on it instead. So, mov­ing on:

The first prob­lem I had was that by default, FlickrRSS could dis­play images, but had no options for dis­play­ing the title of the image and the descrip­tion from flickr. My design plans called for this data. So first, I had to dig around in the Flickr API, look through the dif­fer­ent feed types ‚and look at the source code of my flickr RSS feed to see if it pro­vided what I needed. It did, but unfor­tu­nately, the area of the feed that pro­vided that also pro­vided a damned “JeremyT has posted a photo:” and an img tag includ­ing the image before even run­ning the descrip­tion. This infor­ma­tion needed to be stripped. It was pretty easy for me to fig­ure out how to write the PHP to start dis­play­ing that infor­ma­tion, and even style it. But I needed to fig­ure out how to take that infor­ma­tion and strip out the img tag and the “JeremyT has posted a photo:” string. This took me down the rab­bit hole of PHP func­tions and oper­a­tors and all a bunch of stuff that I under­stand at a basic level due to all the work I’ve put into Actionscript at the day job. Eventually, through Google-​​fu, I found str_​replace, and that worked fine. There’s prob­a­bly a bet­ter func­tion, but I couldn’t find it. I also used strip­tags, and pro­vided a list of tags that were okay. Paragraph, bold, ital­ics, and so on.

I describe it, and it sounds so easy, but the con­stant tweak­ing, the upload­ing and test­ing, then test­ing again–that’s what too so long. And my solu­tion involved hack­ing the code in such a way that my desired effect is going to hap­pen for every image I try and dis­play any­where. I will take advan­tage of this and pro­vide more pop­ups, or I’ll use CSS to hide that infor­ma­tion. I just need to mod­ify some IDs into classes and it’ll be more flexible.

So, one tech­ni­cal hur­dle overcome–three hun­dred to go! God help me, this pro­gram stuff is actu­ally kind of fun. JQuery is espe­cially cool.