Transmit preview link

This commit is contained in:
Michael 2021-07-04 06:30:54 +00:00
parent 3780e51806
commit 5ee0f6e5e1
3 changed files with 43 additions and 19 deletions

View File

@ -126,6 +126,7 @@ class Processor
$data['url'] = $attachment['url'];
$data['mimetype'] = $attachment['mediaType'];
$data['height'] = $attachment['height'] ?? null;
$data['width'] = $attachment['width'] ?? null;
$data['size'] = $attachment['size'] ?? null;
$data['preview'] = $attachment['image'] ?? null;
$data['description'] = $attachment['name'] ?? null;

View File

@ -1112,14 +1112,6 @@ class Receiver
'image' => $pageImage,
];
break;
case 'as:Link':
$attachlist[] = [
'type' => str_replace('as:', '', JsonLD::fetchElement($attachment, '@type')),
'mediaType' => JsonLD::fetchElement($attachment, 'as:mediaType', '@value'),
'name' => JsonLD::fetchElement($attachment, 'as:name', '@value'),
'url' => JsonLD::fetchElement($attachment, 'as:href', '@id')
];
break;
case 'as:Image':
$mediaType = JsonLD::fetchElement($attachment, 'as:mediaType', '@value');
$imageFullUrl = JsonLD::fetchElement($attachment, 'as:url', '@id');
@ -1181,7 +1173,10 @@ class Receiver
'type' => str_replace('as:', '', JsonLD::fetchElement($attachment, '@type')),
'mediaType' => JsonLD::fetchElement($attachment, 'as:mediaType', '@value'),
'name' => JsonLD::fetchElement($attachment, 'as:name', '@value'),
'url' => JsonLD::fetchElement($attachment, 'as:url', '@id')
'url' => JsonLD::fetchElement($attachment, 'as:url', '@id'),
'height' => JsonLD::fetchElement($attachment, 'as:height', '@value'),
'width' => JsonLD::fetchElement($attachment, 'as:width', '@value'),
'image' => JsonLD::fetchElement($attachment, 'as:image', '@id')
];
}
}

View File

@ -1298,10 +1298,24 @@ class Transmitter
}
$urls[] = $attachment['url'];
$attachments[] = ['type' => 'Document',
$attach = ['type' => 'Document',
'mediaType' => $attachment['mimetype'],
'url' => $attachment['url'],
'name' => $attachment['description']];
if (!empty($attachment['height'])) {
$attach['height'] = $attachment['height'];
}
if (!empty($attachment['width'])) {
$attach['width'] = $attachment['width'];
}
if (!empty($attachment['preview'])) {
$attach['image'] = $attachment['preview'];
}
$attachments[] = $attach;
}
}
@ -1316,10 +1330,24 @@ class Transmitter
}
$urls[] = $attachment['url'];
$attachments[] = ['type' => 'Document',
$attach = ['type' => 'Document',
'mediaType' => $attachment['mimetype'],
'url' => $attachment['url'],
'name' => $attachment['description']];
if (!empty($attachment['height'])) {
$attach['height'] = $attachment['height'];
}
if (!empty($attachment['width'])) {
$attach['width'] = $attachment['width'];
}
if (!empty($attachment['preview'])) {
$attach['image'] = $attachment['preview'];
}
$attachments[] = $attach;
}
// Currently deactivated, since it creates side effects on Mastodon and Pleroma.
// It will be activated, once this cleared.