[19742] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: FancyBox Lightbox |
---|
[20068] | 4 | Version: auto |
---|
[19742] | 5 | Description: Display pictures in a lightbox (with fancybox). |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=488 |
---|
| 7 | Author: Winson |
---|
| 8 | Author URI: http://www.WinsonAlbums.com |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | add_event_handler('loc_begin_picture', 'load_Fancybox'); |
---|
| 13 | |
---|
| 14 | function 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 | |
---|
| 26 | var $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 | |
---|
| 39 | add_event_handler('render_element_content','winson_picture_content',EVENT_HANDLER_PRIORITY_NEUTRAL+10,2); |
---|
| 40 | |
---|
| 41 | function winson_picture_content($content, $element_info) |
---|
| 42 | { |
---|
| 43 | preg_match('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$content,$match); |
---|
| 44 | if(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 | } |
---|
| 47 | return $content; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | ?> |
---|