aboutsummaryrefslogtreecommitdiffstats
path: root/include/photo/photo_driver.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-12-28 13:28:49 -0800
committerfriendica <info@friendica.com>2013-12-28 13:28:49 -0800
commit1d0fddd39c50205f697b040aab1655b282afa53d (patch)
tree23c1c98766daeb37f3089246b50d247279aadc35 /include/photo/photo_driver.php
parent2cafe172dc2ea3ed968abe90ce35cec0e4b81580 (diff)
downloadvolse-hubzilla-1d0fddd39c50205f697b040aab1655b282afa53d.tar.gz
volse-hubzilla-1d0fddd39c50205f697b040aab1655b282afa53d.tar.bz2
volse-hubzilla-1d0fddd39c50205f697b040aab1655b282afa53d.zip
things can now have (consistent sized) photos - plus I found a couple of issues with duplicate notifications and contact photos not getting an album name (it was crossed with filename). The last one doesn't matter as neither is used, but it was wrong so it has been corrected. Oh and thing photos weren't working at all because the form element name was different than what the module was looking for. But that had never been tested as I was waiting to get the import/resize finished. Next up for that module is display and deletion of things; but the priority is pretty low.
Diffstat (limited to 'include/photo/photo_driver.php')
-rw-r--r--include/photo/photo_driver.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 3d8ee2196..4896f300b 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -513,20 +513,28 @@ function guess_image_type($filename, $headers = '') {
}
-function import_profile_photo($photo,$xchan) {
+function import_profile_photo($photo,$xchan,$thing = false) {
$a = get_app();
+ $flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN);
+ $album = (($thing) ? 'Things' : 'Contact Photos');
+
logger('import_profile_photo: updating channel photo from ' . $photo . ' for ' . $xchan, LOGGER_DEBUG);
- $r = q("select resource_id from photo where xchan = '%s' and scale = 4 limit 1",
- dbesc($xchan)
- );
- if($r) {
- $hash = $r[0]['resource_id'];
- }
- else {
+ if($thing)
$hash = photo_new_resource();
+ else {
+ $r = q("select resource_id from photo where xchan = '%s' and (photo_flags & %d ) scale = 4 limit 1",
+ dbesc($xchan),
+ intval(PHOTO_XCHAN)
+ );
+ if($r) {
+ $hash = $r[0]['resource_id'];
+ }
+ else {
+ $hash = photo_new_resource();
+ }
}
$photo_failure = false;
@@ -544,7 +552,7 @@ function import_profile_photo($photo,$xchan) {
$img->scaleImageSquare(175);
- $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => 'Contact Photos', 'photo_flags' => PHOTO_XCHAN, 'scale' => 4);
+ $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_flags' => $flags, 'scale' => 4);
$r = $img->save($p);