source: extensions/File_Uploader/plugin_pdf2tab/include/picture.inc.php @ 19680

Last change on this file since 19680 was 19680, checked in by julien1311, 11 years ago

language link update

  • 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
4function pdf2tab_add_links_picture($content, $element_info) {
5        include_once('constants.inc.php');
6
7        if (in_array(strtolower(substr(strrchr($element_info['file'], "."),1)), $supported_extensions)) {
8                $content = pdf2tab_add_link_image($content, $element_info);
9                $content = pdf2tab_add_link_beside_image($content, $element_info);
10        }
11       
12        return $content;
13}
14
15function pdf2tab_add_link_image($content, $element_info) {
16        preg_match('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$content,$match);
17        $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);
18       
19        return $content;
20}
21
22function pdf2tab_add_link_beside_image($content, $element_info) {
23        $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>';
24       
25        return $content;
26}
27?>
Note: See TracBrowser for help on using the repository browser.