issue #2170 update picture tpl to embed pdf reader

Add default config pdf_viewer_filesize_threshold
Add function to get number of PDF pages
Add translations
update picture.php to send pdf filesize threshold and nb page to tpl
update picture.tpl to add number of pages for PDF
picture_content.tpl update for new config name and add translation functions. use embed for pdf if file ext = pdf
This commit is contained in:
HWFord
2024-06-20 11:51:55 +02:00
parent 138f23d32f
commit 983d943548
8 changed files with 63 additions and 1 deletions
+8
View File
@@ -234,6 +234,14 @@ y.callService(
</div>
{/if}
{if isset($PDF_NB_PAGES) and $current.path_ext=="pdf" }
<div id="Pages" class="imageInfo">
<dt>{'Pages'|@translate}</dt>
<dd>{$PDF_NB_PAGES}</dd>
</tr>
{/if}
{if $display_info.rating_score and isset($rate_summary)}
<div id="Average" class="imageInfo">
<dt>{'Rating score'|@translate}</dt>
+14 -1
View File
@@ -4,7 +4,20 @@
{footer_script}var error_icon = "{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png"{/footer_script}
{/if}
<img class="file-ext-{if isset($current.file_ext)}{$current.file_ext}{/if} path-ext-{if isset($current.path_ext)}{$current.path_ext}{/if}" {if (isset($current.path_ext) and $current.path_ext == 'svg')} src="{$current.path}" {elseif $current.selected_derivative->is_cached()}src="{$current.selected_derivative->get_url()}"{$current.selected_derivative->get_size_htm()}{else}src="{$ROOT_URL}{$themeconf.img_dir}/ajax_loader.gif" data-src="{$current.selected_derivative->get_url()}"{/if} alt="{$ALT_IMG}" id="theMainImage" usemap="#map{$current.selected_derivative->get_type()}" title="{if isset($COMMENT_IMG)}{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}{else}{$current.TITLE_ESC} - {$ALT_IMG}{/if}">
{if isset($current.path_ext) and $current.path_ext == 'pdf' and $current.filesize < $PDF_VIEWER_FILESIZE_THRESHOLD}
<div>
<embed src="{$ROOT_URL}{$current.path}" type="application/pdf" />
</div>
{else}
<img class="file-ext-{if isset($current.file_ext)}{$current.file_ext}{/if} path-ext-{if isset($current.path_ext)}{$current.path_ext}{/if}" {if (isset($current.path_ext) and $current.path_ext == 'svg')} src="{$current.path}" {elseif $current.selected_derivative->is_cached()}src="{$current.selected_derivative->get_url()}"{$current.selected_derivative->get_size_htm()}{else}src="{$ROOT_URL}{$themeconf.img_dir}/ajax_loader.gif" data-src="{$current.selected_derivative->get_url()}"{/if} alt="{$ALT_IMG}" id="theMainImage" usemap="#map{$current.selected_derivative->get_type()}" title="{if isset($COMMENT_IMG)}{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}{else}{$current.TITLE_ESC} - {$ALT_IMG}{/if}">
{if isset($current.path_ext) and $current.path_ext == 'pdf' and $current.filesize > $PDF_VIEWER_FILESIZE_THRESHOLD}
<div class="pdf-too-heavy">
{'The PDF you requested is too large to display on this page.'|translate}</br>
<a href="{$ROOT_URL}{$current.path}" target="_blank">{'Click here to display it'|translate}</a>
</div>
{/if}
{/if}
{foreach from=$current.unique_derivatives item=derivative key=derivative_type}{strip}
<map name="map{$derivative->get_type()}">
+9
View File
@@ -414,6 +414,15 @@ TD.calDayCellFull, TD.calDayCellEmpty {
text-align: center;
}
.pdf-too-heavy {
margin-top: 20px;
margin-bottom: 20px;
}
.pdf-too-heavy a {
text-decoration: underline;
}
#imageInfos {
position: relative; /*for IE7 positioning of "who can see this photo"*/
min-height: 120px;