aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php36
1 files changed, 25 insertions, 11 deletions
diff --git a/include/text.php b/include/text.php
index a0c2689af..c0f8c0fb1 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1714,19 +1714,33 @@ function prepare_body(&$item,$attach = false,$opts = false) {
$photo = '';
$is_photo = ((($item['verb'] === ACTIVITY_POST) && ($item['obj_type'] === ACTIVITY_OBJ_PHOTO)) ? true : false);
- if($is_photo) {
-
+ if ($is_photo) {
$object = json_decode($item['obj'],true);
+ $ptr = null;
+ if (array_key_exists('url',$object) && is_array($object['url'])) {
+ if (array_key_exists(0,$object['url'])) {
+ foreach ($object['url'] as $link) {
+ if(array_key_exists('width',$link) && $link['width'] >= 640 && $link['width'] <= 1024) {
+ $ptr = $link;
+ }
+ }
+ if (! $ptr) {
+ $ptr = $object['url'][0];
+ }
+ }
+ else {
+ $ptr = $object['url'];
+ }
- // 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="_blank" rel="nofollow noopener" ><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="_blank" rel="nofollow noopener"><img style="max-width:' . $object['link'][$scale]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][$scale]['href'])) . '"></a>';
+ // if original photo width is > 640px make it a cover photo
+ if ($ptr) {
+ if (array_key_exists('width',$ptr) && $ptr['width'] > 640) {
+ $photo = '<a href="' . zid(rawurldecode($object['id'])) . '" target="_blank" rel="nofollow noopener"><img style="max-width:' . $ptr['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($ptr['href'])) . '"></a>';
+ }
+ else {
+ $item['body'] = '[zmg]' . $ptr['href'] . '[/zmg]' . "\n\n" . $item['body'];
+ }
+ }
}
}