source: extensions/pdf2tab/include/picture.inc.php @ 27856

Last change on this file since 27856 was 19811, checked in by julien1311, 12 years ago

add an admin page to choose the extension to handle

  • Property svn:eol-style set to LF
File size: 1.1 KB
Line 
1<?php
2add_event_handler('render_element_content','pdf2tab_add_links_picture',EVENT_HANDLER_PRIORITY_NEUTRAL+10,2);
3
4load_language('plugin.lang', PDF2TAB_PATH);
5
6function pdf2tab_add_links_picture($content, $element_info) {
7        global $conf;
8       
9        $conf_pdf2tab = unserialize($conf['pdf2tab']);
10       
11        if (in_array(strtolower(substr(strrchr($element_info['file'], "."),1)), $conf_pdf2tab['extensions'])) {
12                $content = pdf2tab_add_link_image($content, $element_info);
13                $content = pdf2tab_add_link_beside_image($content, $element_info);
14        }
15       
16        return $content;
17}
18
19function pdf2tab_add_link_image($content, $element_info) {
20        preg_match('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$content,$match);
21        $content = str_replace($match[0],'<a href="'.$element_info['element_url'].'" target="_blank" title="'.l10n('pdf2tab_tooltip').'">'.$match[0].'</a>',$content);
22       
23        return $content;
24}
25
26function pdf2tab_add_link_beside_image($content, $element_info) {
27        $content .= '<p class="imageComment"><a href="'.$element_info['element_url'].'" target="_blank" title="'.l10n('pdf2tab_tooltip').'">'.l10n('pdf2tab_tooltip').'</a>';
28       
29        return $content;
30}
31?>
Note: See TracBrowser for help on using the repository browser.