aboutsummaryrefslogtreecommitdiffstats
path: root/mod/profile_photo.php
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-09-08 19:51:52 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-09-08 19:51:52 -0700
commite8d431c2f641221712cce974eced27d600c168c1 (patch)
treec64477a9e4e492623d988536624a3bf3232f7aed /mod/profile_photo.php
parent0f4c012321a61e6525f55b5aca656e547e360685 (diff)
downloadvolse-hubzilla-e8d431c2f641221712cce974eced27d600c168c1.tar.gz
volse-hubzilla-e8d431c2f641221712cce974eced27d600c168c1.tar.bz2
volse-hubzilla-e8d431c2f641221712cce974eced27d600c168c1.zip
issues with "use this photo for profile photo" #36
Diffstat (limited to 'mod/profile_photo.php')
-rw-r--r--mod/profile_photo.php32
1 files changed, 27 insertions, 5 deletions
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 13923a655..9f57c3b9d 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -130,7 +130,7 @@ function profile_photo_post(&$a) {
if($r) {
$base_image = $r[0];
- $base_image['data'] = dbunescbin($base_image['data']);
+ $base_image['data'] = (($r[0]['os_storage']) ? @file_get_contents($base_image['data']) : dbunescbin($base_image['data']));
$im = photo_factory($base_image['data'], $base_image['type']);
if($im->is_valid()) {
@@ -332,7 +332,7 @@ function profile_photo_content(&$a) {
goaway($a->get_baseurl() . '/profiles');
}
- $r = q("SELECT `data`, `type` FROM photo WHERE id = %d and uid = %d limit 1",
+ $r = q("SELECT `data`, `type`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1",
intval($r[0]['id']),
intval(local_channel())
@@ -342,9 +342,31 @@ function profile_photo_content(&$a) {
return;
}
- $ph = photo_factory(dbunescbin($r[0]['data']), $r[0]['type']);
- // go ahead as if we have just uploaded a new photo to crop
- profile_photo_crop_ui_head($a, $ph);
+ if(intval($r[0]['os_storage']))
+ $data = @file_get_contents($r[0]['data']);
+ else
+ $data = dbunescbin($r[0]['data']);
+
+ $ph = photo_factory($data, $r[0]['type']);
+ $smallest = 0;
+ if($ph->is_valid()) {
+ // go ahead as if we have just uploaded a new photo to crop
+ $i = q("select resource_id, scale from photo where resource_id = '%s' and uid = %d order by scale",
+ dbesc($r[0]['resource_id']),
+ intval(local_channel())
+ );
+
+ if($i) {
+ $hash = $i[0]['resource_id'];
+ foreach($i as $ii) {
+ if(intval($ii['scale']) < 2) {
+ $smallest = intval($ii['scale']);
+ }
+ }
+ }
+ }
+
+ profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
}
$profiles = q("select id, profile_name as name, is_default from profile where uid = %d",