document slideshow automatic image resize

skala
Juan Carlos Raña 14 years ago
parent c742eb1433
commit 0799fc2342
  1. 2
      main/document/slideshow.inc.php
  2. 62
      main/document/slideshow.php
  3. 19
      main/document/slideshowoptions.php

@ -40,7 +40,7 @@ function resize_image($image, $target_width, $target_height, $slideshow = 0) {
$new_sizes = api_resize_image($image, $target_width, $target_height);
$result[] = $new_sizes['height'];
$result[] = $new_sizes['width'];
} else {
} else {
$size = api_getimagesize($image);
$result[] = $size['height'];
$result[] = $size['width'];

@ -151,7 +151,11 @@ echo '<br />';
// If we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
if (isset($_POST['Submit'])) {
// We come from slideshowoptions.php
//$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']);
$_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']);
if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') {
//echo "resizing";
$_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']);
@ -227,6 +231,7 @@ if ($slide_id != 'all') {
$image_height = $image_height_width[0];
$image_width = $image_height_width[1];
$height_width_tags = null;
if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') {
$height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
@ -260,7 +265,59 @@ if ($slide_id != 'all') {
if ($path == '/') {
$path = '';
}
echo "<img src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">";
list($width, $height) = getimagesize($image);
//auto resize
if($_SESSION["image_resizing"]!="noresizing" && $_SESSION["image_resizing"]!="resizing" ){
?>
<script type="text/javascript">
var initial_width='<?php echo $width; ?>';
var initial_height='<?php echo $height; ?>';
document.write ('<img id="image" src="<?php echo 'download.php?doc_url='.$path.'/'.$image_files_only[$slide]; ?>" width="'+initial_width+'" height="'+initial_height+'" border="0" alt="<?php echo $image_files_only[$slide] ;?>" >');
var height = window.innerHeight -320;
var width = window.innerWidth -360;
function resizeImage() {
var resize_factor_width = width / initial_width;
var resize_factor_height = height / initial_height;
var delta_width = width - initial_width * resize_factor_height;
var delta_height = height - initial_height * resize_factor_width;
if (delta_width > delta_height) {
width = Math.ceil(initial_width * resize_factor_height);
height= Math.ceil(initial_height * resize_factor_height);
}
else if(delta_width < delta_height) {
width = Math.ceil(initial_width * resize_factor_width);
height = Math.ceil(initial_height * resize_factor_width);
}
else {
width = Math.ceil(width);
height = Math.ceil(height);
}
document.getElementById('image').style.height = height +"px";
document.getElementById('image').style.width = width +"px";
};
if (initial_height>height || initial_width>width) {
document.getElementById('image').onload = resizeImage;
window.onresize = resizeImage;
}
</script>
<?php
}
else{
echo "<img src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">";
}
echo '</a>';
echo '</td>';
echo '</tr>';
@ -279,8 +336,7 @@ if ($slide_id != 'all') {
$aux = explode('.', htmlspecialchars($image_files_only[$slide]));
$ext = $aux[count($aux) - 1];
echo $image_files_only[$slide].' <br />';
list($width, $high) = getimagesize($image);
echo $width.' x '.$high.' <br />';
echo $width.' x '.$height.' <br />';
echo round((filesize($image)/1024), 2).' KB';
echo ' - '.$ext;
echo '</td>';

@ -109,7 +109,24 @@ echo '</div>';
<div><?php echo get_lang('_no_resizing_comment');?>
</div>
</div>
<div>
<div class="label">
<input class="checkbox" name="radio_resizing" type="radio" onClick="disableresizing()" value="autoresizing" <?php
if ($image_resizing == 'resizing_auto' || $image_resizing == '') {
echo ' checked';
}
?>>
<?php echo get_lang('_resizing').' ('.get_lang('Auto').')';?>
</div>
<div><?php echo get_lang('_resizing_comment').' ('.get_lang('Auto').')';?>
</div>
</div>
<div>
<div class="label">
<input class="checkbox" name="radio_resizing" type="radio" onClick="javascript: enableresizing();" value="resizing" <?php

Loading…
Cancel
Save