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

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

move 2 files

  • 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        include_once('include/constants.inc.php');
8
9        if (in_array(strtolower(substr(strrchr($element_info['file'], "."),1)), $supported_extensions)) {
10                $content = pdf2tab_add_link_image($content, $element_info);
11                $content = pdf2tab_add_link_beside_image($content, $element_info);
12        }
13       
14        return $content;
15}
16
17function pdf2tab_add_link_image($content, $element_info) {
18        preg_match('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$content,$match);
19        $content = str_replace($match[0],'<a href="'.$element_info['element_url'].'" target="_blank" title="'.l10n('Open the file in a new tab').'">'.$match[0].'</a>',$content);
20       
21        return $content;
22}
23
24function pdf2tab_add_link_beside_image($content, $element_info) {
25        $content .= '<p class="imageComment"><a href="'.$element_info['element_url'].'" target="_blank" title="'.l10n('Open the file in a new tab').'">'.l10n('Open the file in a new tab').'</a>';
26       
27        return $content;
28}
29?>
Note: See TracBrowser for help on using the repository browser.