Skip to content
Permalink
Browse files

Change:images smaller than x(def:250kb) are kept, if browser-native t…

…ype; updates #720
  • Loading branch information...
clickos committed Jun 18, 2015
1 parent e174f80 commit 52feb5ef44060d392fcf5b7d71fab215aed78d83
Showing with 19 additions and 11 deletions.
  1. +1 −0 htdocs/config2/settings-dist.inc.php
  2. +2 −2 htdocs/lib2/logic/picture.class.php
  3. +16 −9 htdocs/picture.php
@@ -316,6 +316,7 @@
$opt['logic']['pictures']['dir'] = $opt['rootpath'] . 'images/uploads'; // Ocprop
$opt['logic']['pictures']['url'] = 'http://devel.opencaching.de/images/uploads';
$opt['logic']['pictures']['maxsize'] = 6000*1024;
$opt['logic']['pictures']['unchg_size'] = 250*1024;
if (extension_loaded('imagick'))
$opt['logic']['pictures']['extensions'] = 'jpg;jpeg;gif;png;bmp;tif;psd;pcx;svg;xpm';
else
@@ -109,7 +109,7 @@ function setFilenames($sFilename)
if (strpos($sFilename, '.') === false)
return;
$sExtension = 'jpg';//mb_strtolower(substr($sFilename, strrpos($sFilename, '.') + 1));
$sExtension = mb_strtolower(substr($sFilename, strrpos($sFilename, '.') + 1));
$this->sFileExtension = $sExtension;
$sUUID = $this->getUUID();
@@ -401,12 +401,12 @@ function delete($restore=false)
$this->setArchiveFlag($restore);
sql("DELETE FROM `pictures` WHERE `id`='&1'", $this->nPictureId);
$this->resetArchiveFlag();
$filename = $this->getFilename();
// archive picture if picture record has been archived
if (sql_value("SELECT `id` FROM `pictures_modified` WHERE `id`='&1'",
0, $this->getPictureId()) != 0)
{
$filename = $this->getFilename();
@rename($filename, $this->deleted_filename($filename));
}
else
@@ -121,17 +121,24 @@
if ($bError == false)
{
$picture->setFilenames($_FILES['file']['name']);
$picture->setLocal(1);
// try saving and shrinking if > PICTURE_MAX_LONG_SIDE file and record
if (!$picture->shrink($_FILES['file']['tmp_name'],PICTURE_MAX_LONG_SIDE))
{
$tpl->assign('errorfile', ERROR_UPLOAD_UNKNOWN);
$bError = true;
list($fname,$ext)=explode('.',$_FILES['file']['name'],2);
// try saving file if smaller unchg_size and browser native format
if (in_array(mb_strtolower($ext), array('gif','png','jpg','jpeg'))
&&($_FILES['file']['size'] < $opt['logic']['pictures']['unchg_size'])){
$picture->setFilenames($_FILES['file']['name']);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $picture->getFilename()))
{
$bError = true;
}
}
// try saving as jpg and shrinking if > PICTURE_MAX_LONG_SIDE file
else {
$picture->setFilenames(mb_strtolower($fname).'.jpg');
if (!$picture->shrink($_FILES['file']['tmp_name'],PICTURE_MAX_LONG_SIDE)) $bError = true;
}
else if ($picture->save())
//try to save in db
if ( !$bError && $picture->save())
{
if ($redirect == '')
$redirect = $picture->getPageLink();

0 comments on commit 52feb5e

Please sign in to comment.
You can’t perform that action at this time.