aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-06-23 15:52:04 +0000
committerMario <mario@mariovavti.com>2021-06-23 15:52:04 +0000
commit6e91bee0ba605b938bddf0570e747d6d7be1c712 (patch)
tree8fa11dc01ab4114510105f6171b91951037d18bd /include/text.php
parentc6d872d1773a0470c9a707e7fe1ae610699bc8dd (diff)
downloadvolse-hubzilla-6e91bee0ba605b938bddf0570e747d6d7be1c712.tar.gz
volse-hubzilla-6e91bee0ba605b938bddf0570e747d6d7be1c712.tar.bz2
volse-hubzilla-6e91bee0ba605b938bddf0570e747d6d7be1c712.zip
some work on streamlining mod photos
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'];
+ }
+ }
}
}