aboutsummaryrefslogtreecommitdiffstats
path: root/mod/photos.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-05-23 01:01:04 -0700
committerfriendica <info@friendica.com>2012-05-23 01:01:04 -0700
commit61dba985c14ebcfd20d18b579aee9b781f98bc23 (patch)
tree93cd7fe6c2b9b0cc5851cb8324b5f6591d990f7f /mod/photos.php
parent8ffb65ceef4de1b1088ace577682812cba6016af (diff)
downloadvolse-hubzilla-61dba985c14ebcfd20d18b579aee9b781f98bc23.tar.gz
volse-hubzilla-61dba985c14ebcfd20d18b579aee9b781f98bc23.tar.bz2
volse-hubzilla-61dba985c14ebcfd20d18b579aee9b781f98bc23.zip
photo rotation
Diffstat (limited to 'mod/photos.php')
-rw-r--r--mod/photos.php58
1 files changed, 57 insertions, 1 deletions
diff --git a/mod/photos.php b/mod/photos.php
index 082947bdb..3ce6f9934 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -287,6 +287,7 @@ function photos_post(&$a) {
if(($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
+
$desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
$rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : '');
$item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0);
@@ -300,7 +301,61 @@ function photos_post(&$a) {
if(! strlen($albname))
$albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
+
+
+ if((x($_POST,'rotate') !== false) && (intval($_POST['rotate']) == 1)) {
+ logger('rotate');
+
+ $r = q("select * from photo where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
+ if(count($r)) {
+ $ph = new Photo($r[0]['data']);
+ if($ph->is_valid()) {
+ $ph->rotate(270);
+
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+
+ $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
+ dbesc($ph->imageString()),
+ intval($height),
+ intval($width),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
+
+ if($width > 640 || $height > 640) {
+ $ph->scaleImage(640);
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+ $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1",
+ dbesc($ph->imageString()),
+ intval($height),
+ intval($width),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
+ }
+
+ if($width > 320 || $height > 320) {
+ $ph->scaleImage(320);
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+
+ $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 2 limit 1",
+ dbesc($ph->imageString()),
+ intval($height),
+ intval($width),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
+ }
+ }
+ }
+ }
$p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
dbesc($resource_id),
@@ -1105,7 +1160,7 @@ function photos_content(&$a) {
$photo = array(
'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.jpg',
'title'=> t('View Full Size'),
- 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg'
+ 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg' . '?f=&_u=' . datetime_convert('','','','ymdhis')
);
if($nextlink)
@@ -1185,6 +1240,7 @@ function photos_content(&$a) {
$edit_tpl = get_markup_template('photo_edit.tpl');
$edit = replace_macros($edit_tpl, array(
'$id' => $ph[0]['id'],
+ '$rotate' => t('Rotate CW'),
'$album' => template_escape($ph[0]['album']),
'$newalbum' => t('New album name'),
'$nickname' => $a->data['user']['nickname'],