Fixing Flickr FAlbum rewrite rules, thumbnails, javascripts and more …
FAlbum is a WordPress Plug-in that adds your Flickr photo albums to your blog without redirecting the viewer to Flickr or leaving your blog. It is very useful and unique, I have always needed that plugin on my blog, however, some features needed a lot of digging into the code to fix or to get it working. So, I am going to describe a step by step installation of this plugin then will show how to fix.
installtion
Fixing rewrite rules
Please do not test before completing all steps, or you will have a lot of trouble with cache.
-
/*
-
function falbum_action_parse_query($wp_query) {
-
if (defined('FALBUM') && constant('FALBUM')) {
-
$wp_query->is_404 = false;
-
}
-
}
-
-
-
add_action('parse_query', 'falbum_action_parse_query');
-
*/
-
function falbum_rewrite() {
-
#These are commented for wordpress 2.5.1
-
#it used to work with older version but notime to check changes for wp_rewrite class
-
#global $wp_rewrite;
-
#$wp_rewrite->add_rule('(photos)/.+','index.php?pagename=$matches[1]');
-
preg_match_all("#photos/(?:([^/]+)/([^/]+)/?)?(?:([^/]+)/([^/]+)/?)?(?:([^/]+)/([^/]+)/?)?(?:([^/]+)/([^/]+)/?)?#is",$_SERVER['REQUEST_URI'],$matches);
-
-
for($i=1;$i<count($matches);$i++){
-
$_GET[$matches[$i][0]] = $matches[++$i][0];
-
#new for 2.5.1 , check the previous comment
-
#change the number to match your page id
-
$GLOBALS['page_id'] = 7;
-
}
-
}
-
-
}
-
falbum_rewrite();
Fixing inline FAlbum tags ([ fa:p:id=.... ])
-
if ($size == ’sq') {
-
$size = '_s';
-
}
-
elseif ($size == 't') {
-
$size = '_t';
-
}
-
elseif ($size == ’s') {
-
$size = '_m';
-
}
-
elseif ($size == 'm') {
-
$size = ”;
-
}
-
elseif ($size == 'l') {
-
$size = 'b';
-
}
-
elseif ($size == 'o') {
-
$size = '_o';
-
}
-
with
-
if ($size == ’sq') {
-
$size = ’s';
-
}
-
Fixing Javascripts
with
-
falbum_photo_id = '<?php echo $photo_id; ?>';
-
falbum_title = '<?php echo preg_replace('/[\n|\r]/','',htmlspecialchars($title, ENT_QUOTES)); ?>';
-
falbum_desc = '<?php echo preg_replace('/[\n|\r]/','',htmlspecialchars($description_orig, ENT_QUOTES)); ?>';
-
falbum_nodesc = '<?php echo $no_description_text; ?>';
-
-
falbum_next_page = '<?php echo $next_page; ?>';
-
falbum_next_id = '<?php echo $next_id; ?>';
-
falbum_prev_page = '<?php echo $prev_page; ?>';
-
falbum_prev_id = '<?php echo $prev_id; ?>';
-
-
falbum_album = '<?php echo $album; ?>';
-
falbum_tags = '<?php echo $in_tags; ?>';
-
-
falbum_post_value = '<?php echo $post_value; ?>';
-
-
falbum_makeEditable('falbum-photo-desc');
-
falbum_makeEditable('falbum-photo-title');
-
falbum_enable_post_helper();
-
<?php endif; ?>
-
-
//jQuery('#pageprev-').click(function(){falbum_show_photo('prev');return false;}).set('href','#');
-
//jQuery('#pagenext-').click(function(){falbum_show_photo('next');return false;}).set('href','#');
-
//jQuery('#falbum_photo_link').click(function(){falbum_show_photo('next');return false;}).set('href','#');
-
-
falbum_prefetch('<?php echo $next_image; ?>');
-
with
-
falbum.photo_id = '<?php echo $photo_id; ?>';
-
falbum.title = '<?php echo preg_replace('/[\n|\r]/','',htmlspecialchars($title, ENT_QUOTES)); ?>';
-
falbum.desc = '<?php echo preg_replace('/[\n|\r]/','',htmlspecialchars($description_orig, ENT_QUOTES)); ?>';
-
falbum.nodesc = '<?php echo $no_description_text; ?>';
-
-
falbum.next_page = '<?php echo $next_page; ?>';
-
falbum.next_id = '<?php echo $next_id; ?>';
-
falbum.prev_page = '<?php echo $prev_page; ?>';
-
falbum.prev_id = '<?php echo $prev_id; ?>';
-
-
falbum.album = '<?php echo $album; ?>';
-
falbum.tags = '<?php echo $in_tags; ?>';
-
-
falbum.post_value = '<?php echo $post_value; ?>';
-
-
falbum.makeEditable('falbum-photo-desc');
-
falbum.makeEditable('falbum-photo-title');
-
falbum.enable_post_helper();
-
<?php endif; ?>
-
-
falbum.prefetch('<?php echo $next_image; ?>');
-
Edit WordPress Theme to work with FALlbum:
-
<?php
-
/*
-
Template Name: FAlbum
-
*/
-
?>
-
<?php
-
-
//Hack to set WP page id
-
$page_id = 7; //Change this to match your sites WP page id of new Photos page
-
-
if ($page_id != null) {
-
$post->ID = $page_id;
-
$wp_query->is_home = false;
-
$wp_query->is_page = true;
-
$wp_query->queried_object->ID = $page_id;
-
$wp_query->queried_object_id = $page_id;
-
}
-
-
get_header();
-
-
-
?>
-
-
<script type="text/javascript" src="<?php echo get_settings(’siteurl'); ?>/wp-content/plugins/falbum/res/falbum.js"></script>
-
<script type="text/javascript" src="<?php echo get_settings(’siteurl'); ?>/wp-content/plugins/falbum/res/jquery.js"></script>
-
<?php if ($falbum->can_edit) { ?><script type="text/javascript" src="<?php echo get_settings(’siteurl'); ?>/wp-content/plugins/falbum/res/prototype.js"></script><?php } ?>
-
-
-
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
-
<div id="content" class="narrowcolumn">
-
-
<?php $falbum->show_photos(); ?>
-
-
</div>
-
-
<?php get_sidebar(); ?>
-
-
<?php get_footer(); ?>
-
<?php
-
require_once(ABSPATH.'/wp-content/plugins/falbum/falbum.php');
-
?>
-
<?php if ($falbum->is_album_page()) { ?>
-
<?php } else { ?>
-
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
-
<?php } ?>
That should do it, you can view a demo on my albums page
and now I'm trying to get xml-sitemaps and FAlbum to play nice together…not sure I have the time to do it!
Adding FAlbum URLs to XML-Sitemap WordPress Plugin


November 22nd, 2007 at 2:19 pm
[...] I mentioned on my previous post yesterday about Fixing FAlbum Plugin that I’m trying to add support for Google XML Sitemaps Plugin to FAlbum so that all URLs [...]
December 19th, 2007 at 2:45 am
[...] Fixing Flickr FAlbum rewrite rules, thumbnails, javascripts and more … :: GadElKareem FAlbum is a WordPress Plugin that adds your Flickr photo albums to your blog. However, some features needed a lot of digging into the code to fix or to get it working. So, here is a step by step installation of this plugin, with fixes. This entry was written by premasagar, posted on December 18, 2007 at 6:00 am, filed under Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL. « Links for 2007-12-16 [del.icio.us] [...]
July 12th, 2008 at 4:55 pm
Thanks a lot! I am preparing my own blog and this really helped me out! At first, the Show Exif was not working. After I followed your steps the problem was solved!
Greetings,
Damir