aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-12-07 10:50:26 +0000
committerMario <mario@mariovavti.com>2022-12-07 10:50:26 +0000
commitabae5de4d8cf864b7a40445cb63191f09f17c248 (patch)
tree0a22c416be3647b47df9d6387c20783b43f30c75
parent6952c5a3f5b2eb975b530aad48f3bbd57bcc1451 (diff)
downloadvolse-hubzilla-abae5de4d8cf864b7a40445cb63191f09f17c248.tar.gz
volse-hubzilla-abae5de4d8cf864b7a40445cb63191f09f17c248.tar.bz2
volse-hubzilla-abae5de4d8cf864b7a40445cb63191f09f17c248.zip
when uploading a image file, embed it in the item. otherwise attach it
-rw-r--r--include/attach.php18
1 files changed, 16 insertions, 2 deletions
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'],