From 9713436f497a031e4369130dda40b415ff285fd8 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 2 May 2018 18:23:42 -0700 Subject: backend work to allow admin to delete photos. Still requires frontend work to give admin access to either the photos and/or the delete link. --- include/photos.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 9ae0e6874..495043bbf 100644 --- a/include/photos.php +++ b/include/photos.php @@ -786,17 +786,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. * -- cgit v1.2.3 From 3c8de7b59d010f8273370c720aafde80067f77d7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 7 May 2018 23:57:17 -0700 Subject: use imagemagick first stage thumbnail for cover photos, if configured --- include/photos.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 495043bbf..2d2c9cc13 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.'); -- cgit v1.2.3 From aac5fd96cc9ea03a329234f6b2bd8b12a0f4ae5f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 15 May 2018 16:51:04 -0700 Subject: provide function to fetch photo contents from url --- include/photos.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 2d2c9cc13..9fb872700 100644 --- a/include/photos.php +++ b/include/photos.php @@ -1011,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 -- cgit v1.2.3 From 156010050c874eb51f8d2b2334d36909f99e732c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 26 Jun 2018 17:19:32 -0700 Subject: imagick converter: -thumbnail doesn't preserve exif, -resize does --- include/photos.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 9fb872700..d0c5f77fc 100644 --- a/include/photos.php +++ b/include/photos.php @@ -80,8 +80,8 @@ function photo_upload($channel, $observer, $args) { if($imagick_path && @file_exists($imagick_path)) { $tmp_name = $args['os_syspath'] . '-001'; $newsize = photo_calculate_scale(array_merge($args['getimagesize'],['max' => $max_thumb])); - $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $args['os_syspath']) . ' -thumbnail ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name); - // logger('imagick thumbnail command: ' . $cmd); + $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $args['os_syspath']) . ' -resize ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name); + logger('imagick thumbnail command: ' . $cmd); for($x = 0; $x < 4; $x ++) { exec($cmd); if(file_exists($tmp_name)) { @@ -97,7 +97,7 @@ function photo_upload($channel, $observer, $args) { $imagedata = @file_get_contents($tmp_name); $filesize = @filesize($args['os_syspath']); - @unlink($tmp_name); +// @unlink($tmp_name); } else { $imagedata = @file_get_contents($args['os_syspath']); -- cgit v1.2.3