aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorredmatrix <mike@macgirvin.com>2016-09-27 18:11:04 -0700
committerredmatrix <mike@macgirvin.com>2016-09-27 18:11:04 -0700
commiteff2e6c7950df6a08fceb1eb0b9ab737e600763a (patch)
treec95733d9441ca83d879fd7eccb622687c584bd8d /Zotlabs/Module
parent3bf0a27e4505881e9a8c118f5025aa7a3495e54e (diff)
downloadvolse-hubzilla-eff2e6c7950df6a08fceb1eb0b9ab737e600763a.tar.gz
volse-hubzilla-eff2e6c7950df6a08fceb1eb0b9ab737e600763a.tar.bz2
volse-hubzilla-eff2e6c7950df6a08fceb1eb0b9ab737e600763a.zip
make the fetching of the default profile photo hookable, and document the hook
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Photo.php48
1 files changed, 31 insertions, 17 deletions
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index a16206299..d37ae07ac 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -59,20 +59,33 @@ class Photo extends \Zotlabs\Web\Controller {
}
$uid = $person;
-
- $r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1",
- intval($resolution),
- intval($uid),
- intval(PHOTO_PROFILE)
- );
- if($r) {
- $data = dbunescbin($r[0]['content']);
- $mimetype = $r[0]['mimetype'];
+
+ $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ];
+ call_hooks('get_profile_photo',$d);
+
+ $resolution = $d['resolution'];
+ $uid = $d['channel_id'];
+ $default = $d['default'];
+ $data = $d['data'];
+ $mimetype = $d['mimetype'];
+
+ if(! $data) {
+ $r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1",
+ intval($resolution),
+ intval($uid),
+ intval(PHOTO_PROFILE)
+ );
+ if($r) {
+ $data = dbunescbin($r[0]['content']);
+ $mimetype = $r[0]['mimetype'];
+ }
+ if(intval($r[0]['os_storage']))
+ $data = file_get_contents($data);
}
- if(intval($r[0]['os_storage']))
- $data = file_get_contents($data);
- if(! isset($data)) {
+ if(! $data) {
$data = file_get_contents($default);
+ }
+ if(! $mimetype) {
$mimetype = 'image/png';
}
}
@@ -88,6 +101,7 @@ class Photo extends \Zotlabs\Web\Controller {
Project link: https://github.com/Retina-Images/Retina-Images
License link: http://creativecommons.org/licenses/by/3.0/
*/
+
$cookie_value = false;
if (isset($_COOKIE['devicePixelRatio'])) {
$cookie_value = intval($_COOKIE['devicePixelRatio']);
@@ -114,15 +128,15 @@ class Photo extends \Zotlabs\Web\Controller {
}
// If using resolution 1, make sure it exists before proceeding:
- if ($resolution == 1)
- {
+ if($resolution == 1) {
$r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
dbesc($photo),
intval($resolution)
- );
- if (!($r))
+ );
+ if(! $r) {
$resolution = 2;
- }
+ }
+ }
$r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
dbesc($photo),