I post images from Flickr on misc Web Boards regularly, and today I wrote a small Perl script to help me along:
The script is available here: kvisberg.net/scripts/flickr2bbc.pl
#!/usr/bin/perl -w # # This script was developed by Ole Bendik Kvisberg (olekvi at kvisberg.net), # # This script is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. use strict; use Getopt::Long; use File::Basename; my $help = 0; my $flickrname = 'olekvi'; # From Flickr.com: # Flickr Community Guidelines specify that if you post a Flickr photo on # an external website, the photo must link back to its photo page my $nolink = 0; GetOptions ("flickrname=s" => $flickrname, "nolink" => $nolink, "help" => $help); my $url = shift; if ($help or !$url) { usage(); } createbbc($url); sub usage { printf ("Usage: %s [OPTION] [PHOTOURL]n", basename($0)); print "Creates BBCode to insert Flickr photo on web forumsnn"; print " -f --flickrname your flickr username (i.e 'olekvi')n"; print " -n, --nolink skip link (Flickr says you shouldn't!)n"; print " -h, --help display this help and exitn"; exit; } sub createbbc { my $photourl = shift; unless ($photourl =~ m!^http://farmd+.static.flickr.com/d+/(d+)_w+.jpg$!) { printf ("Invalid Flickr photo url:n%sn", $photourl); exit; } my $linkurl = sprintf("http://www.flickr.com/photos/%s/%s/", $flickrname, $1); my $photobbc = sprintf("[IMG]%s[/IMG]", $photourl); if ($nolink) { printf ("%sn", $photobbc); } else { printf ("[URL=%s]%s[/URL]n", $linkurl, $photobbc); } }






Flickr now supports this without any script:
Share this ->
Grab the HTML/BBCode ->
BBCode