From 0ba3c227955f39523fce2f50cdee58c326744fe8 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 25 Feb 2022 10:39:52 +0100 Subject: [PATCH] #271 - Added image size placeholders for media snippets --- CHANGELOG.md | 1 + src/dashboardWebView/components/Media/Item.tsx | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cc165d5..75632be7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - [#248](https://github.com/estruyf/vscode-front-matter/issues/248): Added support for front matter highlighting to all file types specified in `frontMatter.content.supportedFileTypes` - [#255](https://github.com/estruyf/vscode-front-matter/issues/255): Added support for default values on block fields / data creation - [#257](https://github.com/estruyf/vscode-front-matter/issues/257): Allow preview images to be used in multi-dimensional fields +- [#271](https://github.com/estruyf/vscode-front-matter/issues/271): Added image size placeholders for media snippets ### ⚡️ Optimizations diff --git a/src/dashboardWebView/components/Media/Item.tsx b/src/dashboardWebView/components/Media/Item.tsx index 54e259f8..9e7a651a 100644 --- a/src/dashboardWebView/components/Media/Item.tsx +++ b/src/dashboardWebView/components/Media/Item.tsx @@ -1,6 +1,6 @@ import { Messenger } from '@estruyf/vscode/dist/client'; import { Menu } from '@headlessui/react'; -import { ClipboardIcon, CodeIcon, EyeIcon, PencilIcon, PhotographIcon, PlusIcon, TrashIcon } from '@heroicons/react/outline'; +import { ClipboardIcon, CodeIcon, PencilIcon, PhotographIcon, PlusIcon, TrashIcon } from '@heroicons/react/outline'; import { basename, dirname } from 'path'; import * as React from 'react'; import { useEffect } from 'react'; @@ -95,6 +95,8 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi snippet = snippet?.replace("{alt}", alt || ""); snippet = snippet?.replace("{caption}", caption || ""); snippet = snippet?.replace("{filename}", basename(relPath || "")); + snippet = snippet?.replace("{mediaWidth}", media?.dimensions?.width?.toString() || ""); + snippet = snippet?.replace("{mediaHeight}", media?.dimensions?.height?.toString() || ""); Messenger.send(DashboardMessage.insertPreviewImage, { image: parseWinPath(relPath) || "",