Navigation Menu

Skip to content

Commit

Permalink
feature 2548 (multiple sizes): adapt the web API method pwg.images.ad…
Browse files Browse the repository at this point in the history
…d (used

by pLoader, Digikam, Lightroom, iPhoto), pwg.images.checkFiles (pLoader only).

The "resize" parameter was removed for pwg.images.add since this behavior
becomes the default behavior in Piwigo 2.4.

Just like pwg.images.addSimple, pwg.images.add now uses the add_uploaded_file
function (next step is to merge pwg.images.add and pwg.images.addSimple)


git-svn-id: http://piwigo.org/svn/trunk@12906 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Jan 17, 2012
1 parent a7f3907 commit f7421e5
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 151 deletions.
13 changes: 13 additions & 0 deletions admin/include/functions.php
Expand Up @@ -2307,4 +2307,17 @@ function clear_derivative_cache_rec($path, $pattern)
return $rmdir;
}
}

function delete_element_derivatives($ids)
{
// todo
if (!is_array($ids))
{
$ids = array($ids);
}

// for now I do a massive clear, to be removed once the function is
// properly implemented
clear_derivative_cache();
}
?>
25 changes: 12 additions & 13 deletions admin/include/functions_upload.inc.php
Expand Up @@ -150,7 +150,7 @@ function save_upload_form_config($data, &$errors=array())
return false;
}

function add_uploaded_file($source_filepath, $original_filename=null, $categories=null, $level=null, $image_id=null)
function add_uploaded_file($source_filepath, $original_filename=null, $categories=null, $level=null, $image_id=null, $original_md5sum=null)
{
// 1) move uploaded file to upload/2010/01/22/20100122003814-449ada00.jpg
//
Expand All @@ -163,7 +163,15 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie

global $conf, $user;

$md5sum = md5_file($source_filepath);
if (isset($original_md5sum))
{
$md5sum = $original_md5sum;
}
else
{
$md5sum = md5_file($source_filepath);
}

$file_path = null;

if (isset($image_id))
Expand Down Expand Up @@ -234,7 +242,7 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie
}
else
{
copy($source_filepath, $file_path);
rename($source_filepath, $file_path);
}

if (pwg_image::get_library() != 'gd')
Expand Down Expand Up @@ -291,23 +299,14 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie
$insert = array(
'file' => pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)),
'date_available' => $dbnow,
'tn_ext' => 'jpg',
'path' => preg_replace('#^'.preg_quote(PHPWG_ROOT_PATH).'#', '', $file_path),
'filesize' => $file_infos['filesize'],
'width' => $file_infos['width'],
'height' => $file_infos['height'],
'md5sum' => $md5sum,
'added_by' => $user['id'],
);

if (isset($high_infos))
{
$insert['has_high'] = 'true';
$insert['high_filesize'] = $high_infos['filesize'];
$insert['high_width'] = $high_infos['width'];
$insert['high_height'] = $high_infos['height'];
}


if (isset($level))
{
$insert['level'] = $level;
Expand Down

0 comments on commit f7421e5

Please sign in to comment.