Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * FancyBoxThumbsK extension
- * by Jason Gill, http://www.gilluminate.com modified by Uwe Schützenmeister, http://idea-sketch.com, Modified by Krusher http://krusher.net
- *
- * Displays thumbnailed images in a Mac-style "lightbox" that floats overtop of web page.
- *
- *
- * Uses: FancyBox - jQuery Plugin
- * Simple and fancy lightbox alternative
- *
- * Examples and documentation at: http://fancybox.net
- *
- * Copyright (c) 2008 - 2011 Janis Skarnelis, Krusher
- * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely.
- * Their support is greatly appreciated.
- *
- * Version: 1.3.4 (11/11/2010)
- * Requires: jQuery v1.3+
- *
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- */
- if ( !defined( 'MEDIAWIKI' ) )
- die( 'This is a MediaWiki extension, and must be run from within MediaWiki.' );
- //Register Credits
- $wgExtensionCredits['other'][] = array(
- 'name' => 'FancyBoxThumbsK',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:FancyBoxThumbs',
- 'author' => '[http://www.gilluminate.com Jason Gill], [http://krusher.net]',
- 'description' => 'Displays thumbnailed images in a Mac-style "lightbox" that floats overtop of web page. A simple and fancy lightbox alternative',
- 'version' => '0.4.K'
- );
- $wgHooks['BeforePageDisplay'][] = 'efBeforePageDisplay';
- function efBeforePageDisplay($out)
- {
- global $wgScriptPath;
- $FBT_Dir = '/extensions/FancyBoxThumbs/fancybox';
- //$out->addScript('<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>');
- $out->addScriptFile($wgScriptPath.$FBT_Dir.'/jquery.fancybox-1.3.4.js');
- $out->addScript('<link rel="stylesheet" href="'.$FBT_Dir.'/jquery.fancybox-1.3.4.css" type="text/css" />');
- ##uses jquery to rewrite the href, rather than traditional php methods that can break the CMS nature of WikiMedia
- $out->addScript('<script type="text/javascript">'
- .'jQuery.noConflict();'
- .'(function($) {'
- .'$(document.body).ready(function() {'
- .'$("a.image").each(function(){'
- .'var img_split1 = $(this).children().first().attr("src").split("/thumb");'
- .' if(img_split1[1] == null) { img_split1[1] = img_split1[0]; img_split1[0] = \'\';};' // Not a thumb but a full image
- .' var img_type = img_split1[1].substr(img_split1[1].length -4);' // cut the last 4 (!) characters to fetch .jpg and jpeg
- .' var img_split2 = img_split1[1].split(img_type);'
- .' var img_src = img_split1[0]+img_split2[0]+"."+img_type;'
- .' var img_src = img_src.replace("..", ".");' // change ..jpg to .jpg but do not change .jpeg
- .' var pieces = img_src.split(\'/\');'
- .' $(this).attr("title", $(this).attr("title") + "<br />Origen: <a style=\"color:#888888;\" href=\"http://www.frikipedia.es/friki/Archivo:"+pieces[pieces.length-1]+"\">" + pieces[pieces.length-1] + "</a>");'
- .' $(this).attr("href", img_src);'
- .'});'
- .'$("a.image").fancybox({"transitionIn":"elastic","transitionOut":"elastic","titlePosition":"inside"});'
- .'});'
- .'})(jQuery)'
- .'</script>');
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement