ID added for list of images in a post

This commit is contained in:
Michael 2022-12-10 19:08:56 +00:00
parent 2362e28c40
commit 870fd1a52b

View file

@ -273,8 +273,8 @@ class BBCode
// Get all linked images with alternative image description // Get all linked images with alternative image description
if (preg_match_all("/\[img=(http[^\[\]]*)\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures, PREG_SET_ORDER)) { if (preg_match_all("/\[img=(http[^\[\]]*)\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures, PREG_SET_ORDER)) {
foreach ($pictures as $picture) { foreach ($pictures as $picture) {
if (Photo::isLocal($picture[1])) { if ($id = Photo::getIdForName($picture[1])) {
$post['images'][] = ['url' => str_replace('-1.', '-0.', $picture[1]), 'description' => $picture[2]]; $post['images'][] = ['url' => str_replace('-1.', '-0.', $picture[1]), 'description' => $picture[2], 'id' => $id];
} else { } else {
$post['remote_images'][] = ['url' => $picture[1], 'description' => $picture[2]]; $post['remote_images'][] = ['url' => $picture[1], 'description' => $picture[2]];
} }
@ -286,8 +286,8 @@ class BBCode
if (preg_match_all("/\[img\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures, PREG_SET_ORDER)) { if (preg_match_all("/\[img\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures, PREG_SET_ORDER)) {
foreach ($pictures as $picture) { foreach ($pictures as $picture) {
if (Photo::isLocal($picture[1])) { if ($id = Photo::getIdForName($picture[1])) {
$post['images'][] = ['url' => str_replace('-1.', '-0.', $picture[1]), 'description' => '']; $post['images'][] = ['url' => str_replace('-1.', '-0.', $picture[1]), 'description' => '', 'id' => $id];
} else { } else {
$post['remote_images'][] = ['url' => $picture[1], 'description' => '']; $post['remote_images'][] = ['url' => $picture[1], 'description' => ''];
} }