source: extensions/Fancybox/main.inc.php @ 26113

Last change on this file since 26113 was 20068, checked in by winson, 12 years ago
File size: 1.4 KB
Line 
1<?php
2/*
3Plugin Name: FancyBox Lightbox
4Version: auto
5Description: Display pictures in a lightbox (with fancybox).
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=488
7Author: Winson
8Author URI: http://www.WinsonAlbums.com
9*/
10
11
12add_event_handler('loc_begin_picture', 'load_Fancybox');
13
14function load_Fancybox()
15{
16  global $template;
17
18  $path = get_root_url().'plugins/'. basename(dirname(__FILE__)).'/';
19
20  $template->append('head_elements', '
21<link rel="stylesheet" type="text/css" href="'.$path.'images/jquery.fancybox-1.3.4.css">
22<script type="text/javascript" src="'.$path.'js/jquery.min.js"></script>
23<script type="text/javascript" src="'.$path.'js/jquery.fancybox-1.3.4.pack.js"></script>
24<script type="text/javascript">
25
26var $var143 = jQuery.noConflict();
27$var143(document).ready(function() {
28        $var143("a#single_image").fancybox({
29                "hideOnContentClick": true,
30                "padding":2,
31                "margin":10,
32                "autoScale":true
33        });
34});
35</script>'
36  );
37}
38
39add_event_handler('render_element_content','winson_picture_content',EVENT_HANDLER_PRIORITY_NEUTRAL+10,2);
40
41function winson_picture_content($content, $element_info)
42{
43preg_match('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$content,$match);
44if(isset($match) && count($match)>0){
45        $content = str_replace($match[0],'<a id="single_image" href="'.$element_info['element_url'].'">'.$match[0].'</a>',$content);
46}
47return $content;
48}
49
50
51?>
Note: See TracBrowser for help on using the repository browser.