{if $media->isImage}
{if $thumbnailSize != 'original'}
{if !$removeLinks}
- <a href="{$mediaLink}" data-caption="{$media->title}" class="embeddedAttachmentLink" data-fancybox="attachments">
+ <a href="{$mediaLink}" data-caption="{$media->title}" class="embeddedAttachmentLink" data-fancybox="message-{$activeMessageObjectType}-{$activeMessageID}">
{/if}
<img src="{$thumbnailLink}" alt="{$media->altText}" title="{$media->title}" width="{@$media->getThumbnailWidth($thumbnailSize)}" height="{@$media->getThumbnailHeight($thumbnailSize)}" loading="lazy">
{if !$removeLinks}
type FileProcessorData = {
attachmentID: number;
+ messageObjectID: number | null;
};
function fileInitializationCompleted(element: HTMLElement, file: WoltlabCoreFileElement, editor: HTMLElement): void {
if (file.link !== undefined && file.filename !== undefined) {
const link = document.createElement("a");
link.href = file.link!;
- link.dataset.fancybox = "uploadedAttachments";
+ link.dataset.fancybox =
+ "attachments" + (data.messageObjectID ? `-${(data as FileProcessorData).messageObjectID}` : "");
link.title = file.filename;
link.dataset.caption = file.filename;
link.textContent = file.filename;
if (file.link !== undefined && file.filename !== undefined) {
const link = document.createElement("a");
link.href = file.link;
- link.dataset.fancybox = "uploadedAttachments";
+ link.dataset.fancybox =
+ "attachments" + (data.messageObjectID ? `-${data.messageObjectID}` : "");
link.title = file.filename;
link.dataset.caption = file.filename;
link.textContent = file.filename;
{
return $this->getFile()?->toHtmlElement([
'attachmentID' => $this->attachmentID,
+ 'messageObjectID' => $this->objectID,
]);
}
if (!$hasParentLink && ($attachment->width > ATTACHMENT_THUMBNAIL_WIDTH || $attachment->height > ATTACHMENT_THUMBNAIL_HEIGHT)) {
$result = \sprintf(
<<<'HTML'
- <a href="%s" data-caption="%s" data-fancybox="attachments" class="embeddedAttachmentLink %s" style="width: %s">
+ <a href="%s" data-caption="%s" data-fancybox="message-%s-%d" class="embeddedAttachmentLink %s" style="width: %s">
%s
<span class="embeddedAttachmentLinkEnlarge">
%s
HTML,
$source,
$title,
+ MessageEmbeddedObjectManager::getInstance()->getActiveMessageObjectType(),
+ MessageEmbeddedObjectManager::getInstance()->getActiveMessageID(),
$class,
$width,
$imageElement,
if (!$hasParentLink && $attachment->hasThumbnail() && $attachment->canDownload()) {
$result = \sprintf(
- '<a href="%s" data-caption="%s" data-fancybox="attachments" class="embeddedAttachmentLink %s" style="width: %s">%s%s</a>',
+ '<a href="%s" data-caption="%s" data-fancybox="message-%s-%d" class="embeddedAttachmentLink %s" style="width: %s">%s%s</a>',
StringUtil::encodeHTML($attachment->getLink()),
StringUtil::encodeHTML($attachment->filename),
+ MessageEmbeddedObjectManager::getInstance()->getActiveMessageObjectType(),
+ MessageEmbeddedObjectManager::getInstance()->getActiveMessageID(),
$class,
$width,
$imageElement,
'media' => $media->getLocalizedVersion(MessageEmbeddedObjectManager::getInstance()->getActiveMessageLanguageID()),
'thumbnailSize' => $thumbnailSize,
'width' => $width,
+ 'activeMessageID' => MessageEmbeddedObjectManager::getInstance()->getActiveMessageID(),
+ 'activeMessageObjectType' => MessageEmbeddedObjectManager::getInstance()->getActiveMessageObjectType(),
], true);
} elseif ($media->isVideo() || $media->isAudio()) {
return WCF::getTPL()->fetch('shared_bbcode_wsm', 'wcf', [
return [
'attachmentID' => $attachment->attachmentID,
+ 'messageObjectID' => $attachment->objectID,
];
}
return $this->activeMessageLanguageID;
}
+ /**
+ * @since 6.2
+ */
+ public function getActiveMessageObjectType(): ?string
+ {
+ if (!$this->activeMessageObjectTypeID) {
+ return null;
+ }
+
+ return ObjectTypeCache::getInstance()->getObjectType($this->activeMessageObjectTypeID)?->objectType;
+ }
+
+ /**
+ * @since 6.2
+ */
+ public function getActiveMessageID(): ?int
+ {
+ return $this->activeMessageID;
+ }
+
/**
* Returns all embedded objects of a specific type.
*