1
0
Fork 0

Merge pull request #7447 from annando/ap-alt-outgoing

ActivityPub: We now support transmitting alternative image descriptions
This commit is contained in:
Hypolite Petovan 2019-07-29 01:20:05 -04:00 committed by GitHub
commit b876a339ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1034,7 +1034,7 @@ class Transmitter
// Simplify image codes
$body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $item['body']);
// Grab all pictures and create attachments out of them
// Grab all pictures without alternative descriptions and create attachments out of them
if (preg_match_all("/\[img\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures)) {
foreach ($pictures[1] as $picture) {
$imgdata = Image::getInfoFromURL($picture);
@ -1047,6 +1047,19 @@ class Transmitter
}
}
// Grab all pictures with alternative description and create attachments out of them
if (preg_match_all("/\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures, PREG_SET_ORDER)) {
foreach ($pictures as $picture) {
$imgdata = Image::getInfoFromURL($picture[1]);
if ($imgdata) {
$attachments[] = ['type' => 'Document',
'mediaType' => $imgdata['mime'],
'url' => $picture[1],
'name' => $picture[2]];
}
}
}
return $attachments;
}