aboutsummaryrefslogtreecommitdiffstats
path: root/include/photos.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/photos.php')
-rw-r--r--include/photos.php72
1 files changed, 59 insertions, 13 deletions
diff --git a/include/photos.php b/include/photos.php
index b1391f284..9fb872700 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -84,10 +84,11 @@ function photo_upload($channel, $observer, $args) {
// logger('imagick thumbnail command: ' . $cmd);
for($x = 0; $x < 4; $x ++) {
exec($cmd);
- if(! file_exists($tmp_name)) {
- logger('imagick scale failed. Retrying.');
- continue;
+ if(file_exists($tmp_name)) {
+ break;
}
+ logger('imagick scale failed. Retrying.');
+ continue;
}
if(! file_exists($tmp_name)) {
logger('imagick scale failed. Abort.');
@@ -211,6 +212,10 @@ function photo_upload($channel, $observer, $args) {
$ph->orient($exif);
}
+
+ $ph->clearexif();
+
+
@unlink($src);
$max_length = get_config('system','max_image_length');
@@ -333,10 +338,17 @@ function photo_upload($channel, $observer, $args) {
$lat = $lon = null;
- if($exif && $exif['GPS']) {
- if(feature_enabled($channel_id,'photo_location')) {
- $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
- $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
+ if($exif && feature_enabled($channel_id,'photo_location')) {
+ $gps = null;
+ if(array_key_exists('GPS',$exif)) {
+ $gps = $exif['GPS'];
+ }
+ elseif(array_key_exists('GPSLatitude',$exif)) {
+ $gps = $exif;
+ }
+ if($gps) {
+ $lat = getGps($gps['GPSLatitude'], $gps['GPSLatitudeRef']);
+ $lon = getGps($gps['GPSLongitude'], $gps['GPSLongitudeRef']);
}
}
@@ -775,17 +787,31 @@ function photos_album_get_db_idstr($channel_id, $album, $remote_xchan = '') {
);
}
if ($r) {
- $arr = array();
- foreach ($r as $rr) {
- $arr[] = "'" . dbesc($rr['hash']) . "'" ;
- }
- $str = implode(',',$arr);
- return $str;
+ return ids_to_querystr($r,'hash',true);
+ }
+
+ return false;
+}
+
+function photos_album_get_db_idstr_admin($channel_id, $album) {
+
+ if(! is_site_admin())
+ return false;
+
+ $r = q("SELECT hash from attach where uid = %d and folder = '%s' ",
+ intval($channel_id),
+ dbesc($album)
+ );
+
+ if ($r) {
+ return ids_to_querystr($r,'hash',true);
}
return false;
}
+
+
/**
* @brief Creates a new photo item.
*
@@ -985,3 +1011,23 @@ function profile_photo_set_profile_perms($uid, $profileid = 0) {
}
}
}
+
+function fetch_image_from_url($url,&$mimetype) {
+
+ $redirects = 0;
+ $x = z_fetch_url($url,true,$redirects,[ 'novalidate' => true ]);
+ if($x['success']) {
+ $hdrs = [];
+ $h = explode("\n",$x['header']);
+ foreach ($h as $l) {
+ list($k,$v) = array_map("trim", explode(":", trim($l), 2));
+ $hdrs[strtolower($k)] = $v;
+ }
+ if (array_key_exists('content-type', $hdrs))
+ $mimetype = $hdrs['content-type'];
+
+ return $x['body'];
+ }
+
+ return EMPTY_STR;
+} \ No newline at end of file