Add image preview for texture assets and clipboard image paste - #79
Merged
Conversation
Implements image support for the Markdown editor without loosening the preview's Content-Security-Policy (img-src data: only, no external requests): - Texture references:  now renders in the HTML preview. New MarkdownImageUtils::EmbedTextureImages() rewrites <img> tags whose src is a package path (/Game/, /Engine/, /Plugins/) by loading the UTexture2D, compressing its source pixels to PNG via FImageUtils::CompressImage, and inlining the result as a data:image/png;base64 URI. Unresolvable paths render a red dashed placeholder span (md-missing-image CSS); PNGs over 12 MB are skipped with a warning. Missing packages are pre-checked with DoesPackageExist to avoid load-failure log noise. - Paste Image: new toolbar button/command (Ctrl+Shift+V, Windows-only CF_DIB clipboard read supporting 24/32bpp BI_RGB and BI_BITFIELDS, bottom-up and top-down rows, zeroed-alpha screenshots treated as opaque). Creates a UTexture2D asset with a unique timestamped name under /Game/Markdown/Images/ (TSF_BGRA8 source, sRGB, no mips) and inserts the matching image link at the cursor, with editor notifications for the no-image / failure / success cases. - Editor module now depends on ImageCore (FImage). - Tests: MarkdownImageUtilsTests covering non-package src passthrough (http/data:), missing-texture placeholder output, and no-op inputs. - Docs: README (en/ja) feature bullet, linking-syntax and shortcut table rows, Image Preview removed from Planned Features; CHANGELOG entries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017MsPFParwnXFT1tjnNf27c
Three dummy gauge textures used to verify the Markdown image preview: an opaque 512x64 bar gauge, a 256x256 circular gauge with alpha, and a 500x60 non-power-of-two segmented gauge, plus a short README describing how to use them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017MsPFParwnXFT1tjnNf27c
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds image support to the Markdown editor without loosening the preview's Content-Security-Policy (
img-src data:only — no external requests): project textures referenced with[Alt](/Game/Path/To/Texture)now render in the HTML preview, and a new Paste Image command turns a clipboard image into a texture asset with the link inserted at the cursor. Verified working in the editor with the bundled sample gauge images.Changes
Texture references in the preview (
a772206)MarkdownImageUtils::EmbedTextureImages()rewrites<img>tags whosesrcis a UE package path (/Game/,/Engine/,/Plugins/):UTexture2D, compresses its source pixels to PNG viaFImageUtils::CompressImage, and inlines the result as adata:image/png;base64URI — compatible with the existing CSP, so the preview still makes no network requests[Image not found: ...], newmd-missing-imageCSS)DoesPackageExistto avoid load-failure log noiseUpdatePreview()after broken-link marking and heading-anchor injectionPaste Image from clipboard (
a772206)BI_RGBandBI_BITFIELDS, bottom-up and top-down row order; 32 bpp DIBs with a zeroed alpha channel (common for screenshots) are treated as opaqueUTexture2Dasset under/Game/Markdown/Images/with a unique timestamped name (BGRA8 source, sRGB, no mips for NPOT screenshots)[Name](/Game/Markdown/Images/Name)link at the cursor; the normal debounced preview refresh then embeds itTests & docs
MarkdownImageUtilsTests(categoriesMarkdownAsset.Images.*): non-packagesrcpassthrough (http / data:), missing-texture placeholder output, and no-op inputsImageCoredocs/sample-images/(opaque power-of-two, alpha, and NPOT variants) used for verification (cf2b932)How to test
docs/sample-images/into the Content Browser[HP gauge](/Game/Textures/T_GaugeBar)— the preview should show the image; a bogus path should show the red placeholder; anhttps://image should stay blocked (CSP intact)/Game/Markdown/Images/and the link is insertedMarkdownAsset, run all (includes the newMarkdownAsset.Images.*tests)Notes
🤖 Generated with Claude Code
https://claude.ai/code/session_017MsPFParwnXFT1tjnNf27c
Generated by Claude Code