Merge pull request #12184 from annando/duplicated-media
This fixes duplicated media in quoted posts
This commit is contained in:
commit
53f3454874
1 changed files with 15 additions and 8 deletions
|
@ -2963,7 +2963,7 @@ class Item
|
||||||
|
|
||||||
$body = $item['body'] ?? '';
|
$body = $item['body'] ?? '';
|
||||||
|
|
||||||
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'has-media', 'quote-uri-id'];
|
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'has-media', 'quote-uri-id', 'post-type'];
|
||||||
|
|
||||||
$shared_uri_id = 0;
|
$shared_uri_id = 0;
|
||||||
$shared_links = [];
|
$shared_links = [];
|
||||||
|
@ -3050,7 +3050,7 @@ class Item
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($shared_attachments)) {
|
if (!empty($shared_attachments)) {
|
||||||
$s = self::addVisualAttachments($shared_attachments, $item, $s, true);
|
$s = self::addVisualAttachments($shared_attachments, $shared_item, $s, true);
|
||||||
$s = self::addLinkAttachment($shared_uri_id ?: $item['uri-id'], $shared_attachments, $body, $s, true, []);
|
$s = self::addLinkAttachment($shared_uri_id ?: $item['uri-id'], $shared_attachments, $body, $s, true, []);
|
||||||
$s = self::addNonVisualAttachments($shared_attachments, $item, $s, true);
|
$s = self::addNonVisualAttachments($shared_attachments, $item, $s, true);
|
||||||
$body = BBCode::removeSharedData($body);
|
$body = BBCode::removeSharedData($body);
|
||||||
|
@ -3182,15 +3182,18 @@ class Item
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($attachment['preview'])) {
|
if ($attachment['filetype'] == 'image') {
|
||||||
|
$preview_url = Post\Media::getPreviewUrlForId($attachment['id'], ($attachment['width'] > $attachment['height']) ? Proxy::SIZE_MEDIUM : Proxy::SIZE_LARGE);
|
||||||
|
} elseif (!empty($attachment['preview'])) {
|
||||||
$preview_url = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_LARGE);
|
$preview_url = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_LARGE);
|
||||||
if (self::containsLink($item['body'], $preview_url)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$preview_url = '';
|
$preview_url = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($preview_url && self::containsLink($item['body'], $preview_url)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (($attachment['filetype'] == 'video')) {
|
if (($attachment['filetype'] == 'video')) {
|
||||||
/// @todo Move the template to /content as well
|
/// @todo Move the template to /content as well
|
||||||
$media = Renderer::replaceMacros(Renderer::getMarkupTemplate('video_top.tpl'), [
|
$media = Renderer::replaceMacros(Renderer::getMarkupTemplate('video_top.tpl'), [
|
||||||
|
@ -3222,10 +3225,14 @@ class Item
|
||||||
$trailing .= $media;
|
$trailing .= $media;
|
||||||
}
|
}
|
||||||
} elseif ($attachment['filetype'] == 'image') {
|
} elseif ($attachment['filetype'] == 'image') {
|
||||||
|
$src_url = Post\Media::getUrlForId($attachment['id']);
|
||||||
|
if (self::containsLink($item['body'], $src_url)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image.tpl'), [
|
$media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image.tpl'), [
|
||||||
'$image' => [
|
'$image' => [
|
||||||
'src' => Post\Media::getUrlForId($attachment['id']),
|
'src' => $src_url,
|
||||||
'preview' => Post\Media::getPreviewUrlForId($attachment['id'], ($attachment['width'] > $attachment['height']) ? Proxy::SIZE_MEDIUM : Proxy::SIZE_LARGE),
|
'preview' => $preview_url,
|
||||||
'attachment' => $attachment,
|
'attachment' => $attachment,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue