May
22
(2006)
FlickrStickr module ported to use Curl
Filed under: Uncategorized. Tags: drupal, Flickr, hacking, module.
The FlickrStickr module for Drupal adds the handy Flock-like Flickr Photo Browser, making it easy peasy to add photos from Flickr to content in Drupal. But, the module uses the PHP fopen() command, which is disabled on Dreamhost's servers for security reasons.
So, with some really quick hackery (more like copy-and-pastery, following this example) I ported the module to use curl instead, and it works great. It doesn't seem to be able to insert images into the TinyMCE editor, so you have to toggle back to text mode to insert an image (oh, the irony!)
Basically, the "port" involved changing this:
$fp= fopen("http://www.flickr.com/services/...reallylongurltruncatedhere...", "r");
while (!feof($fp)) {
$buffer= fgets($fp, 4096);
echo $buffer;
}
to this:
$curler = curl_init();
$urlToCurl = "http://www.flickr.com/services/...reallylongurltruncatedhere...");
curl_setopt($curler, CURLOPT_URL, $urlToCurl);
curl_exec($curler);
curl_close($curler);
There were 2 locations that needed changing. Just search for "fopen" and you'll find them. Use the same pattern of changes for both, and test before deploying.






I was planning on doing that – and I agree about the option to use curl or fopen. Not sure how to do that yet…
I would recommend, if you haven’t, you submit a patch to drupal.org, I guess the actual module should probably have a config option to allow you to use CURL or fopen eh???
Thanks for the CURL implementation of this module — it's terrific. My ISP not only disabled fopen(), but did not compile PHP with CURL. The proverbial double-whammy. I'm amazed that this worked, but I was able to use a PHP module which emulates the CURL library (found at http://code.blitzaffe.com/pages/phpclasses/category/52/fileid/7) in combination with your version of the flickrstickr module. Yeah! – Jack
Good suggestion, the TinyMCE image insert is simpler and does exactly what it should. FlickrStickr was pretty good besides the layout issues.
The new version of Flickrstickr is ready! It does not support the curl alternative yet, but it should not be hard to get in there…Read about it then try it!.
Some improvements include –
– Click and drag into tinyMCE enabled textareas
– scroll through all your images in the dock, not just your 10 latest on a specific tag
– image selector is now floatable/dockable for getting to textareas off your visible screen
– integration with lightbox2 module
– storage of images as nodes and in the filesystem for local backup if flickr changes something
cheers,
Ian
Hi,
Great site, I find myself using it as a great drupal reference.
I have a quick question regarding flickrstickr – when I insert an image, I find that it is always inline and flows into text and any subsequent images. I would like each image insert from flickrstickr to be on it’s “own line (ex. block)” and not have an inline layout. Would this be specified in a flickrstickr css file, or part of the drupal theme? I am using TinyMCE and in input format which allows ‘line break’ and ‘url filter’ – perhaps I am doing something wrong here. Do you normally use flickstickr to insert your images in your blog or do you type it our manually with img tags?
Thanks, and again great site.
- TC
TC – I actually reverted to just copying the image URL from Flickr and pasting it into TinyMCE image location field. Not sure why, off the top of my head… Was there a conflict between TinyMCE and FlickrStickr? I forget… But yeah. you should be able to either modify the flickrstickr css file, or add custom stuff to your own (perhaps with an !important thrown in for good measure?)
Hi D’arcy,
Did you try porting the new version of Flickrstickr to curl?
cheers,
Ian
Haven’t yet. I’ve just been using the Flickr “all sizes” page and copying the Medium image embed code…
but of course I’d rather be using FlickrStickr
The TinyMCE integration will be nice. I’ll try porting it as soon as I get a chance.
Ian, the new version sounds awesome! I’ll check it out ASAP and try porting it to curl. Thanks!