diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-10-25 14:33:57 -0700 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-10-25 14:33:57 -0700 |
commit | b67397861c75e8da465d2a730b1e75b6bd0a72ee (patch) | |
tree | 3f9f27b267eb15f435a7e0457017382919b3c962 | |
parent | de15a2ace16f4499945edb90f0e3645ad537ef1f (diff) | |
parent | 911fd6c654435e60167007fd95a4e8ace50806e8 (diff) | |
download | volse-hubzilla-b67397861c75e8da465d2a730b1e75b6bd0a72ee.tar.gz volse-hubzilla-b67397861c75e8da465d2a730b1e75b6bd0a72ee.tar.bz2 volse-hubzilla-b67397861c75e8da465d2a730b1e75b6bd0a72ee.zip |
Merge https://github.com/redmatrix/hubzilla into pending_merge
-rw-r--r-- | include/bb2diaspora.php | 13 | ||||
-rw-r--r-- | include/photos.php | 75 | ||||
-rw-r--r-- | include/text.php | 15 |
3 files changed, 60 insertions, 43 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 95de43ec3..d10ed57eb 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -309,15 +309,10 @@ function bb2diaspora_itembody($item, $force_update = false) { $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']), - 'link' => rawurldecode(get_rel_link($object['link'],'alternate')), - 'width' => $object['width'], - 'height' => $object['height'] - ); - - $photo_bb = '[zrl=' . $photo['link'] . ']' . '[zmg=' . $photo['width'] . 'x' . $photo['height'] . ']' . $photo['url'] . '[/zmg]' . '[/zrl]'; - $item['body'] = (($item['body']) ? $photo_bb . $item['body'] : $photo_bb); + if($object['link'][2]) { + $photo_bb = '[zrl=' . rawurldecode($object['id']) . ']' . '[zmg=' . $object['link'][2]['width'] . 'x' . $object['link'][2]['height'] . ']' . rawurldecode($object['link'][2]['href']) . '[/zmg]' . '[/zrl]'; + $item['body'] = (($item['body']) ? $photo_bb . $item['body'] : $photo_bb); + } } if(($item['diaspora_meta']) && (! $force_update)) { diff --git a/include/photos.php b/include/photos.php index cd2da735c..a8619c372 100644 --- a/include/photos.php +++ b/include/photos.php @@ -188,9 +188,16 @@ function photo_upload($channel, $observer, $args) { if($args['description']) $p['description'] = $args['description']; + $link = array(); + $r0 = $ph->save($p); - $r0width = $ph->getWidth(); - $r0height = $ph->getHeight(); + $link[0] = array( + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $url = rawurlencode(z_root() . '/photo/' . $photo_hash . '-0.' . $ph->getExt()), + 'width' => $ph->getWidth(), + 'height' => $ph->getHeight() + ); if(! $r0) $errors = true; @@ -202,8 +209,13 @@ function photo_upload($channel, $observer, $args) { $p['scale'] = 1; $r1 = $ph->save($p); - $r1width = $ph->getWidth(); - $r1height = $ph->getHeight(); + $link[1] = array( + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $url = rawurlencode(z_root() . '/photo/' . $photo_hash . '-1.' . $ph->getExt()), + 'width' => $ph->getWidth(), + 'height' => $ph->getHeight() + ); if(! $r1) $errors = true; @@ -212,8 +224,13 @@ function photo_upload($channel, $observer, $args) { $p['scale'] = 2; $r2 = $ph->save($p); - $r2width = $ph->getWidth(); - $r2height = $ph->getHeight(); + $link[2] = array( + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $url = rawurlencode(z_root() . '/photo/' . $photo_hash . '-2.' . $ph->getExt()), + 'width' => $ph->getWidth(), + 'height' => $ph->getHeight() + ); if(! $r2) $errors = true; @@ -222,8 +239,13 @@ function photo_upload($channel, $observer, $args) { $p['scale'] = 3; $r3 = $ph->save($p); - $r3width = $ph->getWidth(); - $r3height = $ph->getHeight(); + $link[3] = array( + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $url = rawurlencode(z_root() . '/photo/' . $photo_hash . '-3.' . $ph->getExt()), + 'width' => $ph->getWidth(), + 'height' => $ph->getHeight() + ); if(! $r3) $errors = true; @@ -257,43 +279,32 @@ function photo_upload($channel, $observer, $args) { if($large_photos) { $scale = 1; - $width = $r1width; - $height = $r1height; + $width = $link[1]['width']; + $height = $link[1]['height']; $tag = (($r1) ? '[zmg=' . $width . 'x' . $height . ']' : '[zmg]'); - // Create item object - $href = rawurlencode(z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash); - $url = rawurlencode(z_root() . "/photo/{$photo_hash}-{$scale}.".$ph->getExt()); - $link = array(); - $link[] = array( - 'rel' => 'alternate', - 'type' => 'text/html', - 'href' => $href - ); - - $object = array( - 'type' => ACTIVITY_OBJ_PHOTO, - 'title' => $title, - 'id' => $url, - 'link' => $link, - 'width' => $width, - 'height' => $height - ); } else { $scale = 2; - $width = $r2width; - $height = $r2height; + $width = $link[2]['width']; + $height = $link[2]['height']; $tag = (($r2) ? '[zmg=' . $width . 'x' . $height . ']' : '[zmg]'); } + // Create item object + $object = array( + 'type' => ACTIVITY_OBJ_PHOTO, + 'title' => $title, + 'id' => rawurlencode(z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash), + 'link' => $link + ); + $body = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' - . $tag . z_root() . "/photo/{$photo_hash}-{$scale}.".$ph->getExt() . '[/zmg]' + . $tag . z_root() . "/photo/{$photo_hash}-{$scale}." . $ph->getExt() . '[/zmg]' . '[/zrl]'; // Create item container - if($args['item']) { foreach($args['item'] as $i) { diff --git a/include/text.php b/include/text.php index 11062a1b2..c30be77b8 100644 --- a/include/text.php +++ b/include/text.php @@ -1374,12 +1374,23 @@ function prepare_body(&$item,$attach = false) { $s = prepare_text($item['body'],$item['mimetype'], false); // } - $is_photo = (($item['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false); + $photo = ''; + $is_photo = (($item['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false); if($is_photo) { $object = json_decode($item['object'],true); - $photo = '<a href="' . zid(rawurldecode(get_rel_link($object['link'],'alternate'))) . '" target="_newwin"><img style="max-width:' . $object['width'] . 'px; width:100%; height:auto;" src="'. zid(rawurldecode($object['id'])) . '"></a>'; + + // if original photo width is <= 640px prepend it to item body + if($object['link'][0]['width'] && $object['link'][0]['width'] <= 640) { + $s = '<div class="inline-photo-item-wrapper"><a href="' . zid(rawurldecode($object['id'])) . '" target="_newwin"><img class="inline-photo-item" style="max-width:' . $object['link'][0]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][0]['href'])) . '"></a></div>' . $s; + } + + // if original photo width is > 640px make it a cover photo + if($object['link'][0]['width'] && $object['link'][0]['width'] > 640) { + $scale = ((($object['link'][1]['width'] == 1024) || ($object['link'][1]['height'] == 1024)) ? 1 : 0); + $photo = '<a href="' . zid(rawurldecode($object['id'])) . '" target="_newwin"><img style="max-width:' . $object['link'][$scale]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][$scale]['href'])) . '"></a>'; + } } $prep_arr = array( |