Merge branch 'dev' into 'dev'
Respect thumbnail storage location on image editing See merge request hubzilla/core!1636
This commit is contained in:
commit
6fc2429540
@ -239,95 +239,53 @@ class Photos extends \Zotlabs\Web\Controller {
|
|||||||
intval($page_owner_uid)
|
intval($page_owner_uid)
|
||||||
);
|
);
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
$d = (($r[0]['os_storage']) ? @file_get_contents(dbunescbin($r[0]['content'])) : dbunescbin($r[0]['content']));
|
|
||||||
$ph = photo_factory($d, $r[0]['mimetype']);
|
$ph = photo_factory(@file_get_contents(dbunescbin($r[0]['content'])), $r[0]['mimetype']);
|
||||||
if($ph->is_valid()) {
|
if($ph->is_valid()) {
|
||||||
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
|
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
|
||||||
$ph->rotate($rotate_deg);
|
$ph->rotate($rotate_deg);
|
||||||
|
|
||||||
$width = $ph->getWidth();
|
$edited = datetime_convert();
|
||||||
$height = $ph->getHeight();
|
|
||||||
|
q("update attach set filesize = %d, edited = '%s' where hash = '%s' and uid = %d",
|
||||||
if(intval($r[0]['os_storage'])) {
|
strlen($ph->imageString()),
|
||||||
@file_put_contents($r[0]['content'],$ph->imageString());
|
dbescdate($edited),
|
||||||
$data = $r[0]['content'];
|
|
||||||
$fsize = @filesize($r[0]['content']);
|
|
||||||
q("update attach set filesize = %d where hash = '%s' and uid = %d",
|
|
||||||
intval($fsize),
|
|
||||||
dbesc($resource_id),
|
|
||||||
intval($page_owner_uid)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$data = $ph->imageString();
|
|
||||||
$fsize = strlen($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
$x = q("update photo set edited = '%s', content = '%s', filesize = %d, height = %d, width = %d where resource_id = '%s' and uid = %d and imgscale = 0",
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbescbin($data),
|
|
||||||
intval($fsize),
|
|
||||||
intval($height),
|
|
||||||
intval($width),
|
|
||||||
dbesc($resource_id),
|
dbesc($resource_id),
|
||||||
intval($page_owner_uid)
|
intval($page_owner_uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$ph->saveImage(dbunescbin($r[0]['content']));
|
||||||
|
|
||||||
|
$arr = [
|
||||||
|
'aid' => get_account_id(),
|
||||||
|
'uid' => intval($page_owner_uid),
|
||||||
|
'resource_id' => dbesc($resource_id),
|
||||||
|
'filename' => $r[0]['filename'],
|
||||||
|
'imgscale' => 0,
|
||||||
|
'album' => $r[0]['album'],
|
||||||
|
'os_path' => $r[0]['os_path'],
|
||||||
|
'os_storage' => 1,
|
||||||
|
'os_syspath' => dbunescbin($r[0]['content']),
|
||||||
|
'display_path' => $r[0]['display_path'],
|
||||||
|
'photo_usage' => PHOTO_NORMAL,
|
||||||
|
'edited' => dbescdate($edited)
|
||||||
|
];
|
||||||
|
|
||||||
|
$ph->save($arr);
|
||||||
|
|
||||||
|
unset($arr['photo_usage']);
|
||||||
|
|
||||||
if($width > 1024 || $height > 1024)
|
if($width > 1024 || $height > 1024)
|
||||||
$ph->scaleImage(1024);
|
$ph->scaleImage(1024);
|
||||||
|
$ph->storeThumbnail($arr, PHOTO_RES_1024);
|
||||||
$width = $ph->getWidth();
|
|
||||||
$height = $ph->getHeight();
|
|
||||||
$data = $ph->imageString();
|
|
||||||
$fsize = strlen($data);
|
|
||||||
|
|
||||||
$x = q("update photo set edited = '%s', content = '%s', filesize = %d, height = %d, width = %d where resource_id = '%s' and uid = %d and imgscale = 1",
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbescbin($data),
|
|
||||||
intval($fsize),
|
|
||||||
intval($height),
|
|
||||||
intval($width),
|
|
||||||
dbesc($resource_id),
|
|
||||||
intval($page_owner_uid)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
if($width > 640 || $height > 640)
|
if($width > 640 || $height > 640)
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(640);
|
||||||
|
$ph->storeThumbnail($arr, PHOTO_RES_640);
|
||||||
$width = $ph->getWidth();
|
|
||||||
$height = $ph->getHeight();
|
|
||||||
$data = $ph->imageString();
|
|
||||||
$fsize = strlen($data);
|
|
||||||
|
|
||||||
$x = q("update photo set edited = '%s', content = '%s', filesize = %d, height = %d, width = %d where resource_id = '%s' and uid = %d and imgscale = 2",
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbescbin($data),
|
|
||||||
intval($fsize),
|
|
||||||
intval($height),
|
|
||||||
intval($width),
|
|
||||||
dbesc($resource_id),
|
|
||||||
intval($page_owner_uid)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
if($width > 320 || $height > 320)
|
if($width > 320 || $height > 320)
|
||||||
$ph->scaleImage(320);
|
$ph->scaleImage(320);
|
||||||
|
$ph->storeThumbnail($arr, PHOTO_RES_320);
|
||||||
$width = $ph->getWidth();
|
|
||||||
$height = $ph->getHeight();
|
|
||||||
$data = $ph->imageString();
|
|
||||||
$fsize = strlen($data);
|
|
||||||
|
|
||||||
$x = q("update photo set edited = '%s', content = '%s', filesize = %d, height = %d, width = %d where resource_id = '%s' and uid = %d and imgscale = 3",
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbescbin($data),
|
|
||||||
intval($fsize),
|
|
||||||
intval($height),
|
|
||||||
intval($width),
|
|
||||||
dbesc($resource_id),
|
|
||||||
intval($page_owner_uid)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -508,6 +508,18 @@ abstract class PhotoDriver {
|
|||||||
|
|
||||||
$arr['imgscale'] = $scale;
|
$arr['imgscale'] = $scale;
|
||||||
|
|
||||||
|
if(! array_key_exists('photo_usage', $arr)) {
|
||||||
|
$x = q("SELECT photo_usage FROM photo WHERE resource_id = '%s' AND uid = %d AND imgscale = %d LIMIT 1",
|
||||||
|
dbesc($arr['resource_id']),
|
||||||
|
intval($arr['uid']),
|
||||||
|
intval($arr['imgscale'])
|
||||||
|
);
|
||||||
|
if($x)
|
||||||
|
$arr['photo_usage'] = $r[0]['photo_usage'];
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(boolval(get_config('system','filesystem_storage_thumbnails', 0)) && $scale > 0) {
|
if(boolval(get_config('system','filesystem_storage_thumbnails', 0)) && $scale > 0) {
|
||||||
$channel = \App::get_channel();
|
$channel = \App::get_channel();
|
||||||
$arr['os_storage'] = 1;
|
$arr['os_storage'] = 1;
|
||||||
|
Reference in New Issue
Block a user