[2.x] fix: image preview shows empty src in composer preview#469
Merged
Conversation
The preview() method generates the BBCode that the JS TextFormatter
renders live in the composer (before the post is submitted). It was
missing the thumbnail_url attribute, so the image-preview template's
{@thumbnail_url} resolved to an empty string → src="" in the HTML.
The PHP FormatImagePreview renderer (which injects thumbnail_url) only
runs on post save/render, not during the composer preview.
Fix: include thumbnail_url in the preview BBCode, using $file->thumbnail_url
(stored thumbnail) falling back to $file->url (original file URL) so
the preview always has a valid image src.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Problem
After the thumbnail feature (PR #465), uploading an image with the
image-previewtemplate showed a broken image (src="") in the composer live preview:Root cause
The
preview()method inImagePreviewTemplategenerates the BBCode string that the JavaScript TextFormatter renderer uses for the composer preview (the live preview while typing, before the post is submitted). It was not includingthumbnail_url:The image-preview blade template uses
{@thumbnail_url}as the<img src>. Sincethumbnail_urlwas absent from the BBCode, the JS renderer setsrc="".The PHP
FormatImagePreviewrenderer (which properly injectsthumbnail_url) only runs at post save/render time — not during the composer live preview.Fix
Include
thumbnail_urlin the preview BBCode, using$file->thumbnail_url(the stored thumbnail) falling back to$file->url(the original file URL):Forums without thumbnails generated (e.g. before running the backfill command) will show the full-resolution image in the preview, matching the pre-thumbnail behaviour.
🤖 Generated with Claude Code