• I’m migrating a site from the FAlbum plugin to tantan, but now I’m facing the problem that the shortcodes used by FAlbum to display photos in posts need to be converted to tantan. Those shortcodes look like this:
    [fa:p:t=pglost,id=4076338806,j=l,s=s,l=i]

    I’ve located the function in the Falbum php files which creates the shortcode, but now I’m helpless on how to convert and actually make it work with tantan (plus, my php skills are limited). I’ve started by replacing $falbum with $TanTanFlickrPlugin, which of course doesn’t do the trick yet. Can anyone here help making it work?

    Here’s the code:

    <?
    function falbum_filter($content) {
    	global $TanTanFlickrPlugin;
    	$matches = array ();
    	$content = preg_replace('<code>\<p>(\[fa:(.*?)\].*?)</p></code>ms', '$1', $content);
    	preg_match_all('<code>\[fa:(.*?)\]</code>', $content, $matches);
    	for ($i = 0; $i < count($matches[0]); $i ++) {
    		$s = '';
    		$v = split(":", $matches[1][$i]);
    		$style = '';
    		$album = '';
    		$tag = '';
    		$id = '';
    		$page = NULL;
    		$linkto = '';
    
    		// Defaults
    		$size = 'm';
    		$float = 'left';
    
    		//Parse Parms
    		if (count($v) == 2) {
    			$parms = split(",", $v[1]);
    			for ($index = 0; $index < sizeof($parms); $index ++) {
    				$pv = trim($parms[$index]);
    				$p = split("=", $pv);
    				switch ($p[0]) {
    					case 'a' :
    					case 'album' :
    						$album = $p[1];
    						break;
    
    					case 'j' :
    					case 'justification' :
    						if ($p[1] == 'left' || $p[1] == 'l') {
    							$style = 'float: left; margin: 0px 5px -5px 0px';
    						} else
    							if ($p[1] == 'right' || $p[1] == 'r') {
    								$style = 'float: right; margin: 0px -5px -5px 5px';
    							} else {
    								$style = 'position: relative; margin: 0 auto; text-align: center;';
    							}
    						break;
    
    					case 'l' :
    					case 'linkto' :
    						$linkto = $p[1];
    						break;
    
    					case 'id' :
    						$id = $p[1];
    						break;
    
    					case 'p' :
    					case 'page' :
    						$page = $p[1];
    						break;
    
    					case 's' :
    					case 'size' :
    						$size = $p[1];
    						break;
    
    					case 't' :
    					case 'tag' :
    						$tag = $p[1];
    						break;
    				}
    			}
    		}
    
    		//Parse Action
    		switch ($v[0]) {
    			case 'a' :
    			case 'album' :
    				$s = $TanTanFlickrPlugin->show_album_tn($id);
    				break;
    
    			case 'r' :
    			case 'random' :
    				if ($album == '') {
    					$s = $TanTanFlickrPlugin->show_random(1, $tag, 1, $size);
    				} else {
    					$s = $TanTanFlickrPlugin->show_album_tn($album);
    				}
    				break;
    
    			case 'p' :
    			case 'photo' :
    				//$album, $tags, $photo, $page, $size
    				$s = $TanTanFlickrPlugin->show_single_photo($album, $tag, $id, $page, $size, $linkto);
    				break;
    		}
    		$s = '<div class="falbum-post-box" style="'.$style.'">'.$s.'</div>';
    		$content = str_replace($matches[0][$i], $s, $content);
    	}
    	return $content;
    }
    ?>

Viewing 1 replies (of 1 total)
  • Thread Starter adastra

    (@adastra)

    Can really nobody help? I’m a bit clueless here, as both those plugins aren’t really documented at all…

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: tantan-flickr] FAlbum to tantan shortcode converter’ is closed to new replies.