From 96f23758b4c0e2b997a8c3579639a57f5c533649 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 20 Oct 2015 09:40:32 +0200 Subject: [PATCH 1/3] hubzilla photo object compatibility --- include/ItemObject.php | 16 +++++++++++++++- view/tpl/conv_item.tpl | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/ItemObject.php b/include/ItemObject.php index d5601edf5..0add87510 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -263,7 +263,19 @@ class Item extends BaseObject { localize_item($item); - $body = prepare_body($item,true); + + $is_photo = (($item['obj_type'] == ACTIVITY_OBJ_PHOTO) ? true : false); + if($is_photo) { + $object = json_decode($item['object'],true); + $photo = array( + 'url' => rawurldecode($object['id']) . '?zid=' . $observer['xchan_addr'], + 'link' => rawurldecode(get_rel_link($object['link'],'alternate')) . '?zid=' . $observer['xchan_addr'], + 'width' => $object['width'], + 'height' => $object['height'] + ); + } + + $body .= prepare_body($item,true); // $viewthread (below) is only valid in list mode. If this is a channel page, build the thread viewing link // since we can't depend on llink or plink pointing to the right local location. @@ -323,6 +335,8 @@ class Item extends BaseObject { 'owner_url' => $this->get_owner_url(), 'owner_photo' => $this->get_owner_photo(), 'owner_name' => $this->get_owner_name(), + 'is_photo' => $is_photo, + 'photo' => (($is_photo) ? $photo : ''), // Item toolbar buttons 'like' => $like, diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index 30a007bd6..c16e7d6a6 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -33,6 +33,11 @@
+ {{if $item.is_photo}} +
+ +
+ {{/if}} {{$item.body}} {{if $item.tags}}
From 9cbca24f7a333187961d35a77e5426dc4f2e122e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 22 Oct 2015 10:56:24 +0200 Subject: [PATCH 2/3] photo object compatibility revamped --- include/ItemObject.php | 15 +-------------- include/text.php | 9 ++++++++- view/tpl/conv_item.tpl | 5 ----- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/include/ItemObject.php b/include/ItemObject.php index 0add87510..dea2f75bf 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -264,18 +264,7 @@ class Item extends BaseObject { localize_item($item); - $is_photo = (($item['obj_type'] == ACTIVITY_OBJ_PHOTO) ? true : false); - if($is_photo) { - $object = json_decode($item['object'],true); - $photo = array( - 'url' => rawurldecode($object['id']) . '?zid=' . $observer['xchan_addr'], - 'link' => rawurldecode(get_rel_link($object['link'],'alternate')) . '?zid=' . $observer['xchan_addr'], - 'width' => $object['width'], - 'height' => $object['height'] - ); - } - - $body .= prepare_body($item,true); + $body = prepare_body($item,true); // $viewthread (below) is only valid in list mode. If this is a channel page, build the thread viewing link // since we can't depend on llink or plink pointing to the right local location. @@ -335,8 +324,6 @@ class Item extends BaseObject { 'owner_url' => $this->get_owner_url(), 'owner_photo' => $this->get_owner_photo(), 'owner_name' => $this->get_owner_name(), - 'is_photo' => $is_photo, - 'photo' => (($is_photo) ? $photo : ''), // Item toolbar buttons 'like' => $like, diff --git a/include/text.php b/include/text.php index f4122845e..2a8905efe 100644 --- a/include/text.php +++ b/include/text.php @@ -1440,12 +1440,19 @@ function generate_named_map($location) { function prepare_body(&$item,$attach = false) { + require_once('include/identity.php'); call_hooks('prepare_body_init', $item); unobscure($item); - $s = prepare_text($item['body'],$item['mimetype']); + $is_photo = (($item['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false); + if($is_photo) { + $object = json_decode($item['object'],true); + $s = ''; + } + + $s .= prepare_text($item['body'],$item['mimetype']); $prep_arr = array('item' => $item, 'html' => $s); call_hooks('prepare_body', $prep_arr); diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index c16e7d6a6..30a007bd6 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -33,11 +33,6 @@
- {{if $item.is_photo}} -
- -
- {{/if}} {{$item.body}} {{if $item.tags}}
From 4442da306a6a2ac88c6dd0ab10b21616fb66daf0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 25 Oct 2015 18:02:45 +0100 Subject: [PATCH 3/3] hubzilla compatibility: improve photo item object - we now provide the infos for all available photo sizes --- include/text.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/text.php b/include/text.php index 2a8905efe..c3abaeedf 100644 --- a/include/text.php +++ b/include/text.php @@ -1449,7 +1449,8 @@ function prepare_body(&$item,$attach = false) { $is_photo = (($item['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false); if($is_photo) { $object = json_decode($item['object'],true); - $s = ''; + $scale = ((($object['link'][1]['width'] == 1024) || ($object['link'][1]['height'] == 1024)) ? 1 : 0); + $s = '
'; } $s .= prepare_text($item['body'],$item['mimetype']);