aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-01-24 20:03:35 +0000
committerMario <mario@mariovavti.com>2021-01-24 20:03:35 +0000
commit77793e17c04b1f67c10a83e7877c36a8b11ddbaa (patch)
tree293729c08f5f0193a6445f641b5ac09d43168d3b /include
parente486442eb1fdda0c4efa7eafc6d876b3c2c4b0ea (diff)
parent552796286e4a2a61cc6020b7aa785dc88553e2d0 (diff)
downloadvolse-hubzilla-77793e17c04b1f67c10a83e7877c36a8b11ddbaa.tar.gz
volse-hubzilla-77793e17c04b1f67c10a83e7877c36a8b11ddbaa.tar.bz2
volse-hubzilla-77793e17c04b1f67c10a83e7877c36a8b11ddbaa.zip
Merge branch 'dev' into 'dev'
Add support filesystem storage for xchan profile photos See merge request hubzilla/core!1898
Diffstat (limited to 'include')
-rw-r--r--include/import.php2
-rw-r--r--include/photo/photo_driver.php43
2 files changed, 19 insertions, 26 deletions
diff --git a/include/import.php b/include/import.php
index b512e1f11..8ce582ede 100644
--- a/include/import.php
+++ b/include/import.php
@@ -1469,7 +1469,7 @@ function sync_files($channel, $files) {
fclose($fp);
// Override remote hub thumbnails storage settings
- if(! boolval(get_config('system','filesystem_storage_thumbnails', 0))) {
+ if(! boolval(get_config('system','photo_storage_type', 1))) {
$p['os_storage'] = 0;
$p['content'] = file_get_contents($stored_image);
@unlink($stored_image);
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 1ce2fd6e3..057711f1e 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -205,7 +205,11 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) {
if($thing)
$hash = photo_new_resource();
else {
- $r = q("SELECT resource_id, edited, mimetype, expires, description FROM photo WHERE xchan = '%s' AND photo_usage = %d AND imgscale = 4 LIMIT 1", dbesc($xchan), intval(PHOTO_XCHAN));
+ $r = q("SELECT resource_id, edited, mimetype, expires, description FROM photo WHERE xchan = '%s' AND photo_usage = %d AND imgscale = %d LIMIT 1",
+ dbesc($xchan),
+ intval(PHOTO_XCHAN),
+ intval(PHOTO_RES_PROFILE_300)
+ );
if($r) {
$hash = $r[0]['resource_id'];
$modified = $r[0]['edited'];
@@ -316,26 +320,20 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) {
'filename' => basename($photo),
'album' => $album,
'photo_usage' => $flags,
- 'imgscale' => 4,
'edited' => $modified,
'description' => (array_key_exists('etag', $hdrs) ? $hdrs['etag'] : ''),
'expires' => gmdate('Y-m-d H:i:s', (isset($expires) ? $expires : time() + 86400))
];
- $r = $img->save($p);
- if($r === false)
- $photo_failure = true;
+ $r1 = $img->storeThumbnail($p, PHOTO_RES_PROFILE_300);
$img->scaleImage(80);
- $p['imgscale'] = 5;
- $r = $img->save($p);
- if($r === false)
- $photo_failure = true;
+ $r2 = $img->storeThumbnail($p, PHOTO_RES_PROFILE_80);
$img->scaleImage(48);
- $p['imgscale'] = 6;
- $r = $img->save($p);
- if($r === false)
+ $r3 = $img->storeThumbnail($p, PHOTO_RES_PROFILE_48);
+
+ if($r1 === false || $r2 === false || $r3 === false)
$photo_failure = true;
$photo = z_root() . '/photo/' . $hash . '-4';
@@ -424,31 +422,26 @@ function import_channel_photo($photo, $type, $aid, $uid) {
'resource_id' => $hash,
'filename' => $filename,
'album' => t('Profile Photos'),
- 'photo_usage' => PHOTO_PROFILE,
- 'imgscale' => 4,
+ 'photo_usage' => PHOTO_PROFILE
];
// photo size
$img->scaleImageSquare(300);
- $r = $img->save($p);
- if($r === false)
- $photo_failure = true;
+ $r1 = $img->storeThumbnail($p, PHOTO_RES_PROFILE_300);
// thumb size
$img->scaleImage(80);
- $p['imgscale'] = 5;
- $r = $img->save($p);
- if($r === false)
- $photo_failure = true;
+ $r2 = $img->storeThumbnail($p, PHOTO_RES_PROFILE_80);
// micro size
$img->scaleImage(48);
- $p['imgscale'] = 6;
- $r = $img->save($p);
- if($r === false)
+ $r3 = $img->storeThumbnail($p, PHOTO_RES_PROFILE_48);
+
+ if($r1 === false || $r2 === false || $r3 === false)
$photo_failure = true;
- } else {
+ }
+ else {
logger('Invalid image.');
$photo_failure = true;
}