Commit fecc6589 authored by sylvieg's avatar sylvieg

[FIX]article: better width control - do not distord smaller image

parent 3a91e6f4
......@@ -53,6 +53,7 @@ switch ($_REQUEST["image_type"]) {
$cachefile = $prefs['tmpDir'];
if ($tikidomain) { $cachefile.= "/$tikidomain"; }
$cachefile.= "/$image_cache_prefix.".$_REQUEST["id"];
if (!empty($_REQUEST['width'])) $cachefile .= '_'.$_REQUEST['width'];
// If "reload" parameter is set, recreate the cached image file from database values.
// This does not make sense if "image_type" is "preview".
......@@ -82,7 +83,13 @@ if ( (isset($_REQUEST["reload"])) || (!is_file($cachefile))) {
}
$type = $storedData["image_type"];
$data = $storedData["image_data"];
if ($data["image_data"]) {
if (!empty($_REQUEST['width'])) {
require('lib/images/images.php');
$image = new Image($data);
$image->resizemax($_REQUEST['width']);
$data =& $image->display();
}
if ($data) {
$fp = fopen($cachefile,"wb");
fputs($fp,$data);
fclose($fp);
......
......@@ -63,8 +63,8 @@
title="{if $listpages[ix].show_image_caption and $listpages[ix].image_caption}{$listpages[ix].image_caption}{else}{$listpages[ix].topicName}{/if}">
<img {if $listpages[ix].isfloat eq 'y'}style="margin-right:4px;float:left;"{else}class="articleimage"{/if}
alt="{if $listpages[ix].show_image_caption and $listpages[ix].image_caption}{$listpages[ix].image_caption}{else}{$listpages[ix].topicName}{/if}"
src="article_image.php?image_type=article&amp;id={$listpages[ix].articleId}"
{if !empty($prefs.art_view_img_width)} width="{$prefs.art_view_img_width}"{elseif $listpages[ix].image_x > 0} width="{$listpages[ix].image_x}"{/if}{if $listpages[ix].image_y > 0 } height="{$listpages[ix].image_y}"{/if} />
src="article_image.php?image_type=article&amp;id={$listpages[ix].articleId}{if !empty($prefs.art_view_img_width)}&amp;width={$prefs.art_view_img_width|escape}{/if}"
{if $listpages[ix].image_x > 0} width="{$listpages[ix].image_x}"{/if}{if $listpages[ix].image_y > 0 } height="{$listpages[ix].image_y}"{/if} />
</a>
{else}
{* Intentionally left blank to allow user add an image from somewhere else through the img tag and no other extra image *}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment