Skip to content

Instantly share code, notes, and snippets.

Created September 24, 2010 21:55
Show Gist options
  • Save anonymous/596122 to your computer and use it in GitHub Desktop.
Save anonymous/596122 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Flickr Feed Gallery
Plugin URI: http://www.jaysonjc.com/projects/wordpress-plugins/flickr-feed-gallery
Description: Enables easy integration of Flickr photo feed to a WordPress blog. Configure feed parameters from settings page. Use <code>&lt;?php show_flickr_feed_gallery();?&gt;</code> in your theme or add plugin as a Widget.
Version: 1.1
Author: Jayson Joseph Chacko
Author URI: http://www.jaysonjc.com
*/
function show_flickr_feed_gallery_by_tags($tags = null, $limit = null) {
$gallery = new Flickr_Feed_Gallery();
$options = $gallery->get_flickr_feed_options();
if($tags) {
$options->tags = $tags;
}
if($limit) {
$options->image_limit = $limit;
}
$url = $gallery->get_flickr_json_url($options);
echo ("<span id='ffg_marker_span' style='display:none;'></span>");
echo ("<script> var ffg_options = ['".$gallery->get_flickr_json_url($options)."','".$options->image_size."','".$options->image_limit."']; </script>");
echo ("<style>");
include('flickr-feed-gallery.css');
echo ("</style>");
?>
<script>
(function() {
jQuery(document).ready(ffg_show_image_content);
})();
function ffg_show_image_content() {
jQuery.getJSON(ffg_options[0],
function(result) {
jQuery.each(result.items,
function(i,item) {
ffg_append_img_content(i,item);
if(i+1>=ffg_options[2]) return false;
}
)
}
);
}
function ffg_append_img_content(i,item) {
var img_url = item.media.m;
var iu = img_url.replace("_m",ffg_options[1]);
var content = '<a title="'+item.title+'" href="'+item.link+'" class="ffg_link_css" id="ffg_link_'+i+'">'
content = content+ '<img alt="'+item.title+'" class="ffg_img_css" id="ffg_img_'+i+'"'+' src="'+iu+'">';
content = content + '</a>';
jQuery(content).insertAfter('#ffg_marker_span');
}
</script>
<?php
}
function show_flickr_feed_gallery() {
$gallery = new Flickr_Feed_Gallery();
$options = $gallery->get_flickr_feed_options();
$url = $gallery->get_flickr_json_url($options);
echo ("<span id='ffg_marker_span' style='display:none;'></span>");
echo ("<script> var ffg_options = ['".$gallery->get_flickr_json_url($options)."','".$options->image_size."','".$options->image_limit."']; </script>");
echo ("<style>");
include('flickr-feed-gallery.css');
echo ("</style>");
?>
<script>
(function() {
jQuery(document).ready(ffg_show_image_content);
})();
function ffg_show_image_content() {
jQuery.getJSON(ffg_options[0],
function(result) {
jQuery.each(result.items,
function(i,item) {
ffg_append_img_content(i,item);
if(i+1>=ffg_options[2]) return false;
}
)
}
);
}
function ffg_append_img_content(i,item) {
var img_url = item.media.m;
var iu = img_url.replace("_m",ffg_options[1]);
var content = '<a title="'+item.title+'" href="'+item.link+'" class="ffg_link_css" id="ffg_link_'+i+'">'
content = content+ '<img alt="'+item.title+'" class="ffg_img_css" id="ffg_img_'+i+'"'+' src="'+iu+'">';
content = content + '</a>';
jQuery(content).insertAfter('#ffg_marker_span');
}
</script>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment