mirror of
https://github.com/friendica/friendica
synced 2025-04-25 13:10:11 +00:00
Merge pull request #13107 from annando/unify-link
Unifiy the creation of photo links
This commit is contained in:
commit
ccf94c5424
6 changed files with 42 additions and 24 deletions
|
@ -489,7 +489,7 @@ class Media
|
|||
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
|
||||
foreach ($pictures as $picture) {
|
||||
if (self::isLinkToImagePage($picture[1], $picture[2])) {
|
||||
$body = str_replace($picture[0], '[url=' . str_replace(['-1.', '-2.'], '-0.', $picture[2]) . '][img=' . $picture[2] . ']' . $picture[3] . '[/img][/url]', $body);
|
||||
$body = str_replace($picture[0], Images::getBBCodeByUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2], $picture[3]), $body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ class Media
|
|||
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
|
||||
foreach ($pictures as $picture) {
|
||||
if (self::isLinkToImagePage($picture[1], $picture[2])) {
|
||||
$body = str_replace($picture[0], '[url=' . str_replace(['-1.', '-2.'], '-0.', $picture[2]) . '][img]' . $picture[2] . '[/img][/url]', $body);
|
||||
$body = str_replace($picture[0], Images::getBBCodeByUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2]), $body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1004,19 +1004,7 @@ class Media
|
|||
}
|
||||
|
||||
if ($media['type'] == self::IMAGE) {
|
||||
if (!empty($media['preview'])) {
|
||||
if (!empty($media['description'])) {
|
||||
$body .= "\n[url=" . $media['url'] . "][img=" . $media['preview'] . ']' . $media['description'] . '[/img][/url]';
|
||||
} else {
|
||||
$body .= "\n[url=" . $media['url'] . "][img]" . $media['preview'] . '[/img][/url]';
|
||||
}
|
||||
} else {
|
||||
if (!empty($media['description'])) {
|
||||
$body .= "\n[img=" . $media['url'] . ']' . $media['description'] . '[/img]';
|
||||
} else {
|
||||
$body .= "\n[img]" . $media['url'] . '[/img]';
|
||||
}
|
||||
}
|
||||
$body .= "\n" . Images::getBBCodeByUrl($media['url'], $media['preview'], $media['description'] ?? '');
|
||||
} elseif ($media['type'] == self::AUDIO) {
|
||||
$body .= "\n[audio]" . $media['url'] . "[/audio]\n";
|
||||
} elseif ($media['type'] == self::VIDEO) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue