fixing images plus
- fix isp image $newSize resizement - fix forcing $newSize with a bang on WinOS - convert some message errors to 2.0 style - whitespace cleanup
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<?php #
|
||||
<?php
|
||||
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
# Improved by Vladimir Ajgl (vlada@ajgl.cz) 2008-01-26
|
||||
@ -616,7 +616,6 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
if ($size === false) {
|
||||
$size = $serendipity['thumbSize'];
|
||||
}
|
||||
|
||||
if ($size < 1) {
|
||||
return array(0,0);
|
||||
}
|
||||
@ -629,9 +628,8 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
$f = $t[0];
|
||||
$suf = $t[1];
|
||||
|
||||
|
||||
$infile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $file;
|
||||
# echo 'From: ' . $infile . '<br />';
|
||||
#echo 'From: ' . $infile . '<br />';
|
||||
if ($is_temporary) {
|
||||
$temppath = dirname($thumbname);
|
||||
if (!is_dir($temppath)) {
|
||||
@ -642,7 +640,7 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
$outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $thumbname . '.' . $suf;
|
||||
}
|
||||
$serendipity['last_outfile'] = $outfile;
|
||||
# echo 'To: ' . $outfile . '<br />';
|
||||
#echo 'To: ' . $outfile . '<br />';
|
||||
|
||||
$fdim = @serendipity_getimagesize($infile, '', $suf);
|
||||
if (isset($fdim['noimage'])) {
|
||||
@ -659,7 +657,11 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
}
|
||||
} else {
|
||||
if (is_array($size)) {
|
||||
if ($fdim[0] > $size['width'] && $fdim[1] > $size['height']) {
|
||||
$r = $size;
|
||||
} else {
|
||||
return array(0,0);
|
||||
}
|
||||
} else {
|
||||
$calc = serendipity_calculate_aspect_size($fdim[0], $fdim[1], $size, $serendipity['thumbConstraint']);
|
||||
$r = array('width' => $calc[0], 'height' => $calc[1]);
|
||||
@ -671,11 +673,12 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
if (!$force_resize && serendipity_ini_bool(ini_get('safe_mode')) === false) {
|
||||
$newSize .= '>'; // Tell imagemagick to not enlarge small images, only works if safe_mode is off (safe_mode turns > in to \>)
|
||||
}
|
||||
$cmd = escapeshellcmd($serendipity['convert'] . ' ' . $serendipity['imagemagick_thumb_parameters']) . ' -antialias -resize ' . serendipity_escapeshellarg($newSize) . '\! ' . serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile);
|
||||
$newSize .= '!'; // force the image geometry exactly to given sizes (see https://github.com/s9y/Serendipity/commit/94881ba4c0e3bdd4b5fac510e93977e239171c1c and comments)
|
||||
$cmd = escapeshellcmd($serendipity['convert'] . ' ' . $serendipity['imagemagick_thumb_parameters']) . ' -antialias -resize ' . serendipity_escapeshellarg($newSize) . ' ' . serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile);
|
||||
}
|
||||
exec($cmd, $output, $result);
|
||||
if ($result != 0) {
|
||||
echo '<div class="serendipityAdminMsgError msg_error"><img class="img_error" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</span>';
|
||||
$r = false; // return failure
|
||||
} else {
|
||||
touch($outfile);
|
||||
@ -683,7 +686,6 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
|
||||
unset($output, $result);
|
||||
}
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
@ -719,7 +721,7 @@ function serendipity_scaleImg($id, $width, $height) {
|
||||
$cmd = escapeshellcmd($serendipity['convert']) . ' -scale ' . serendipity_escapeshellarg($width . 'x' . $height) . ' ' . serendipity_escapeshellarg($infile) . ' ' . serendipity_escapeshellarg($outfile);
|
||||
exec($cmd, $output, $result);
|
||||
if ( $result != 0 ) {
|
||||
echo '<div class="serendipityAdminMsgError msg_error"><img class="img_error" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</span>';
|
||||
}
|
||||
unset($output, $result);
|
||||
}
|
||||
@ -766,7 +768,7 @@ function serendipity_rotateImg($id, $degrees) {
|
||||
$cmd = escapeshellcmd($serendipity['convert']) . ' -rotate ' . serendipity_escapeshellarg($degrees) . ' ' . serendipity_escapeshellarg($infile) . ' ' . serendipity_escapeshellarg($outfile);
|
||||
exec($cmd, $output, $result);
|
||||
if ( $result != 0 ) {
|
||||
echo '<div class="serendipityAdminMsgError msg_error"><img class="img_error" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</span>';
|
||||
}
|
||||
unset($output, $result);
|
||||
|
||||
@ -774,7 +776,7 @@ function serendipity_rotateImg($id, $degrees) {
|
||||
$cmd = escapeshellcmd($serendipity['convert']) . ' -rotate ' . serendipity_escapeshellarg($degrees) . ' ' . serendipity_escapeshellarg($infileThumb) . ' ' . serendipity_escapeshellarg($outfileThumb);
|
||||
exec($cmd, $output, $result);
|
||||
if ( $result != 0 ) {
|
||||
echo '<div class="serendipityAdminMsgError msg_error"><img class="img_error" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />'. sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</div>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . sprintf(IMAGICK_EXEC_ERROR, $cmd, $output[0], $result) .'</span>';
|
||||
}
|
||||
unset($output, $result);
|
||||
|
||||
@ -2184,19 +2186,19 @@ function serendipity_directoryACL(&$paths, $type = 'read') {
|
||||
if ($granted === false) {
|
||||
// We are not allowed to access this element
|
||||
if ($debug) {
|
||||
echo "<span class='msg_error'>ACL for " . $info['relpath'] . " DENIED.</span>";
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ACL for ' . $info['relpath'] . " DENIED.</span>";
|
||||
}
|
||||
unset($paths[$idx]);
|
||||
} else {
|
||||
if ($debug) {
|
||||
echo "<span class='msg_success'>ACL for " . $info['relpath'] . " granted.</span>";
|
||||
echo '<span class="msg_success"><span class="icon-ok-circled"></span> ACL for ' . $info['relpath'] . " granted.</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($paths) < $startCount) {
|
||||
if ($debug) {
|
||||
echo "<span class='msg_error'>ACL denied all.</span>";
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ACL denied all.</span>';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -3448,11 +3450,11 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i
|
||||
// Forward user to overview (we don't want the user's back button to rename things again)
|
||||
} else {
|
||||
if (!file_exists($oldfile)) {
|
||||
echo '<span class="msg_error">' . ERROR_FILE_NOT_EXISTS . '</span>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . ERROR_FILE_NOT_EXISTS . '</span>';
|
||||
} elseif (file_exists($newfile)) {
|
||||
echo '<span class="msg_error">' . ERROR_FILE_EXISTS . '</span>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . ERROR_FILE_EXISTS . '</span>';
|
||||
} else {
|
||||
echo '<span class="msg_error">' . ERROR_SOMETHING . '</span>';
|
||||
echo '<span class="msg_error"><span class="icon-attention"></span> ' . ERROR_SOMETHING . '</span>';
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -3477,7 +3479,7 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i
|
||||
'oldDir' => $oldDir,
|
||||
'newDir' => $newDir,
|
||||
'type' => $type,
|
||||
'item_id'=> $item_id,
|
||||
'item_id' => $item_id,
|
||||
'file' => $file,
|
||||
'name' => $pick['name']
|
||||
));
|
||||
@ -3504,7 +3506,7 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i
|
||||
'oldDir' => $oldDir,
|
||||
'newDir' => $newDir,
|
||||
'type' => $type,
|
||||
'item_id'=> $item_id,
|
||||
'item_id' => $item_id,
|
||||
'file' => $file
|
||||
));
|
||||
|
||||
@ -3617,4 +3619,3 @@ function serendipity_checkDirUpload($dir) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user