Photo add function only adds the first file in the array
This commit is contained in:
parent
3c45bbf4d1
commit
109880475a
@ -4,7 +4,11 @@ namespace Lychee\Modules;
|
|||||||
|
|
||||||
final class Import {
|
final class Import {
|
||||||
|
|
||||||
private function photo($path, $albumID = 0, $description = '', $tags = '') {
|
/**
|
||||||
|
* Creates an array similar to a file upload array and adds the photo to Lychee.
|
||||||
|
* @return boolean Returns true when photo import was successful.
|
||||||
|
*/
|
||||||
|
private function photo($path, $albumID = 0) {
|
||||||
|
|
||||||
// No need to validate photo type and extension in this function.
|
// No need to validate photo type and extension in this function.
|
||||||
// $photo->add will take care of it.
|
// $photo->add will take care of it.
|
||||||
@ -21,7 +25,7 @@ final class Import {
|
|||||||
$nameFile[0]['size'] = $size;
|
$nameFile[0]['size'] = $size;
|
||||||
$nameFile[0]['error'] = UPLOAD_ERR_OK;
|
$nameFile[0]['error'] = UPLOAD_ERR_OK;
|
||||||
|
|
||||||
if (!$photo->add($nameFile, $albumID, $description, $tags, true)) return false;
|
if ($photo->add($nameFile, $albumID, true)===false) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -140,7 +144,7 @@ final class Import {
|
|||||||
|
|
||||||
$contains['photos'] = true;
|
$contains['photos'] = true;
|
||||||
|
|
||||||
if (!$this->photo($file, $albumID)) {
|
if ($this->photo($file, $albumID)===false) {
|
||||||
$error = true;
|
$error = true;
|
||||||
Log::error(Database::get(), __METHOD__, __LINE__, 'Could not import file (' . $file . ')');
|
Log::error(Database::get(), __METHOD__, __LINE__, 'Could not import file (' . $file . ')');
|
||||||
continue;
|
continue;
|
||||||
|
@ -79,7 +79,8 @@ final class Photo {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($files as $file) {
|
// Only process the first photo in the array
|
||||||
|
$file = $files[0];
|
||||||
|
|
||||||
// Check if file exceeds the upload_max_filesize directive
|
// Check if file exceeds the upload_max_filesize directive
|
||||||
if ($file['error']===UPLOAD_ERR_INI_SIZE) {
|
if ($file['error']===UPLOAD_ERR_INI_SIZE) {
|
||||||
@ -204,9 +205,6 @@ final class Photo {
|
|||||||
// Use title of file if IPTC title missing
|
// Use title of file if IPTC title missing
|
||||||
if ($info['title']==='') $info['title'] = substr(basename($file['name'], $extension), 0, 30);
|
if ($info['title']==='') $info['title'] = substr(basename($file['name'], $extension), 0, 30);
|
||||||
|
|
||||||
// Use description parameter if set
|
|
||||||
if ($description==='') $description = $info['description'];
|
|
||||||
|
|
||||||
if ($exists===false) {
|
if ($exists===false) {
|
||||||
|
|
||||||
// Set orientation based on EXIF data
|
// Set orientation based on EXIF data
|
||||||
@ -236,7 +234,7 @@ final class Photo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save to DB
|
// Save to DB
|
||||||
$values = array(LYCHEE_TABLE_PHOTOS, $id, $info['title'], $photo_name, $description, $tags, $info['type'], $info['width'], $info['height'], $info['size'], $info['iso'], $info['aperture'], $info['make'], $info['model'], $info['shutter'], $info['focal'], $info['takestamp'], $path_thumb, $albumID, $public, $star, $checksum, $medium);
|
$values = array(LYCHEE_TABLE_PHOTOS, $id, $info['title'], $photo_name, $info['description'], '', $info['type'], $info['width'], $info['height'], $info['size'], $info['iso'], $info['aperture'], $info['make'], $info['model'], $info['shutter'], $info['focal'], $info['takestamp'], $path_thumb, $albumID, $public, $star, $checksum, $medium);
|
||||||
$query = Database::prepare(Database::get(), "INSERT INTO ? (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum, medium) VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')", $values);
|
$query = Database::prepare(Database::get(), "INSERT INTO ? (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum, medium) VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')", $values);
|
||||||
$result = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
|
$result = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
|
||||||
|
|
||||||
@ -245,8 +243,6 @@ final class Photo {
|
|||||||
Response::error('Could not save photo in database!');
|
Response::error('Could not save photo in database!');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call plugins
|
// Call plugins
|
||||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user