Skip to content

Build your personal knowledge base with Trilium Notes

client/image viewer: fix some issues

Adorian Doran202a441792df
diff --git a/apps/client/src/widgets/type_widgets/Attachment.tsx b/apps/client/src/widgets/type_widgets/Attachment.tsx
index 9d38d8d9cb..0bf34b5887 100644
--- a/apps/client/src/widgets/type_widgets/Attachment.tsx
+++ b/apps/client/src/widgets/type_widgets/Attachment.tsx
@@ -182,8 +182,8 @@ function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment,
async function copyAttachmentLinkToClipboard() {
if (attachment.role === "image") {
- const $imageWrapper = refToJQuerySelector(isZoomableImage ? imageViewerWrapper : contentWrapper);
- image.copyImageReferenceToClipboard($imageWrapper.find("img").parent());
+ const $img = refToJQuerySelector(isZoomableImage ? imageViewerWrapper : contentWrapper).find("img");
+ if ($img.length) image.copyImageReferenceToClipboard($img.parent());
} else if (attachment.role === "file") {
const $link = await link.createLink(attachment.ownerId, {
referenceLink: true,
diff --git a/apps/client/src/widgets/type_widgets/Image.tsx b/apps/client/src/widgets/type_widgets/Image.tsx
index 04b0482e61..a4b1b1e627 100644
--- a/apps/client/src/widgets/type_widgets/Image.tsx
+++ b/apps/client/src/widgets/type_widgets/Image.tsx
@@ -23,7 +23,8 @@ export default function Image({ note, ntxId }: TypeWidgetProps) {
// the clipboard gets clean <img> markup without the surrounding zoom/transform containers.
useTriliumEvent("copyImageReferenceToClipboard", ({ ntxId: eventNtxId }) => {
if (eventNtxId !== ntxId) return;
- copyImageReferenceToClipboard(refToJQuerySelector(containerRef).find("img").parent());
+ const $img = refToJQuerySelector(containerRef).find("img");
+ if ($img.length) copyImageReferenceToClipboard($img.parent());
});
useTriliumEvents([ "imageZoomIn", "imageZoomOut", "imageZoomReset" ], ({ ntxId: eventNtxId }, eventName) =>