From abae5de4d8cf864b7a40445cb63191f09f17c248 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 7 Dec 2022 10:50:26 +0000 Subject: when uploading a image file, embed it in the item. otherwise attach it --- include/attach.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index fd418103d..fc146d008 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2105,8 +2105,22 @@ function attach_store_item($channel, $observer, $file) { $arr['verb'] = ACTIVITY_CREATE; $arr['obj_type'] = $type; $arr['title'] = $file['filename']; - $body_str = sprintf(t('%s shared a %s with you'), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $path . ']' . t('file') . '[/zrl]'); - $arr['body'] = $body_str; + + if ($type === 'Image') { + $arr['body'] = '[zrl=' . $path . '][zmg=' . $path . ']' . $file['display_path'] . '[/zmg][/zrl]'; + } + else { + $arr['attach'][] = [ + 'href' => z_root() . '/attach/' . $resource_id, + 'length' => $file['filesize'], + 'type' => $file['filetype'], + 'title' => urlencode($file['filename']), + 'revision' => $file['revision'] + ]; + } + + $body_str = sprintf((($type === 'Image') ? t('%s shared an %s with you') : t('%s shared a %s with you')), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $path . ']' . (($type === 'Image') ? t('image') : t('file')) . '[/zrl]'); + $arr['body'] .= $body_str; $meta = [ 'name' => $file['filename'], -- cgit v1.2.3