Skip to content

Commit

Permalink
Use the good wrapper for image when in web server mode
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 31, 2024
1 parent 63abd9e commit a0d0e60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
18 changes: 15 additions & 3 deletions htdocs/core/lib/website.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,11 @@ function getImagePublicURLOfObject($object, $no = 1, $extName = '')
} else {
$found++;

$image_path = DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($obj->share);
if (defined('USEDOLIBARRSERVER') || defined('USEDOLIBARREDITOR')) {
$image_path = DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($obj->share);
} else {
$image_path = '/wrapper.php?hashp='.urlencode($obj->share);
}
if ($extName) {
//getImageFileNameForSize($dir.$file, '_small')
$image_path .= '&extname='.urlencode($extName);
Expand All @@ -1057,12 +1061,20 @@ function getImagePublicURLOfObject($object, $no = 1, $extName = '')
$i++;
}
if (!$found && $foundnotshared) {
$image_path = DOL_URL_ROOT.'/viewimage.php?modulepart=common&file=nophotopublic.png';
if (defined('USEDOLIBARRSERVER') || defined('USEDOLIBARREDITOR')) {
$image_path = DOL_URL_ROOT.'/viewimage.php?modulepart=common&file=nophotopublic.png';
} else {
$image_path = '/wrapper.php?modulepart=common&file=nophotopublic.png';
}
}
}

if (empty($image_path)) {
$image_path = DOL_URL_ROOT.'/viewimage.php?modulepart=common&file=nophoto.png';
if (defined('USEDOLIBARRSERVER') || defined('USEDOLIBARREDITOR')) {
$image_path = DOL_URL_ROOT.'/viewimage.php?modulepart=common&file=nophoto.png';
} else {
$image_path = '/wrapper.php?modulepart=common&file=nophoto.png';
}
}

return $image_path;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/langs/en_US/website.lang
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ NoPageYet=No pages yet
YouCanCreatePageOrImportTemplate=You can create a new page or import a full website template
SyntaxHelp=Help on specific syntax tips
YouCanEditHtmlSourceckeditor=You can edit HTML source code using the "Source" button in editor.
YouCanEditHtmlSource=<br><span class="fa fa-bug"></span> You can include PHP code into this source using tags <strong>&lt;?php ?&gt;</strong>. The following global variables are available: $conf, $db, $mysoc, $user, $website, $websitepage, $weblangs, $pagelangs.<br><br><span class="fa fa-bug"></span> You can also include content of another Page/Container with the following syntax:<br><strong>&lt;?php includeContainer('alias_of_container_to_include'); ?&gt;</strong><br><br><span class="fa fa-bug"></span> You can make a redirect to another Page/Container with the following syntax (Note: do not output any content before a redirect):<br><strong>&lt;?php redirectToContainer('alias_of_container_to_redirect_to'); ?&gt;</strong><br><br><span class="fa fa-link"></span> To add a link to another page, use the syntax:<br><strong>&lt;a href="alias_of_page_to_link_to.php"&gt;mylink&lt;a&gt;</strong><br><br><span class="fa fa-download"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong>&lt;a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong>&lt;a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;a href="/document.php?hashp=publicsharekeyoffile"&gt;</strong><br>
YouCanEditHtmlSource1=<br><span class="fa fa-image"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper.<br>Example, for an image into documents/medias (open directory for public access), syntax is:<br><strong>&lt;img src="/viewimage.php?modulepart=medias&amp;file=[relative_dir/]filename.ext"&gt;</strong><br>
YouCanEditHtmlSource=<br><span class="fa fa-bug paddingright"></span> You can include PHP code into this source using tags <strong>&lt;?php ?&gt;</strong>. The following global variables are available: $conf, $db, $mysoc, $user, $website, $websitepage, $weblangs, $pagelangs.<br><br><span class="fa fa-bug paddingright"></span> You can also include content of another Page/Container with the following syntax:<br><strong>&lt;?php includeContainer('alias_of_container_to_include'); ?&gt;</strong><br><br><span class="fa fa-bug paddingright"></span> You can make a redirect to another Page/Container with the following syntax (Note: do not output any content before a redirect):<br><strong>&lt;?php redirectToContainer('alias_of_container_to_redirect_to'); ?&gt;</strong><br><br><span class="fa fa-link paddingright"></span> To add a link to another page, use the syntax:<br><strong>&lt;a href="alias_of_page_to_link_to.php"&gt;mylink&lt;a&gt;</strong><br><br><span class="fa fa-download paddingright"></span> To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong>&lt;a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file into documents/medias (open directory for public access), syntax is:<br><strong>&lt;a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext"&gt;</strong><br>For a file shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;a href="/document.php?hashp=publicsharekeyoffile"&gt;</strong><br>
YouCanEditHtmlSource1=<br><span class="fa fa-image paddingright"></span> To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper.<br>Example, for an image into documents/medias (open directory for public access), syntax is:<br><strong>&lt;img src="/viewimage.php?modulepart=medias&amp;file=[relative_dir/]filename.ext"&gt;</strong><br>
YouCanEditHtmlSource2=For an image shared with a share link (open access using the sharing hash key of file), syntax is:<br><strong>&lt;img src="/viewimage.php?hashp=12345679012..."&gt;</strong><br>
YouCanEditHtmlSource3=To get the URL of the image of a PHP object, use<br><strong>&lt;img src="&lt;?php print getImagePublicURLOfObject($object, 1, "_small") ?&gt;"&gt;</strong><br>
YouCanEditHtmlSourceMore=<br>More examples of HTML or dynamic code available on <a href="%s" target="_blank" rel="noopener noreferrer external" class="nofocusvisible">the wiki documentation</a>.<br>
Expand Down
2 changes: 1 addition & 1 deletion htdocs/website/samples/wrapper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

// BEGIN PHP File wrapper.php - DO NOT MODIFY - It is just a copy of file website/samples/wrapper.php
// BEGIN PHP File wrapper.php used to download rss, logo, shared files - DO NOT MODIFY - It is just a copy of file website/samples/wrapper.php
$websitekey = basename(__DIR__);
if (strpos($_SERVER["PHP_SELF"], 'website/samples/wrapper.php')) {
die("Sample file for website module. Can't be called directly.");
Expand Down

0 comments on commit a0d0e60

Please sign in to comment.