File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
src/ui/src/components/document-viewer Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ SPDX-License-Identifier: MIT-0
3131 - Image resolution is preserved by default unless explicitly configured via ` resize_config `
3232 - DPI settings now only apply to PDF files, not to image files
3333 - Resolves issue where PNG files were being converted to lower resolution JPG files
34+ - ** Image File Display in Document Viewer**
35+ - Fixed issue where PNG and JPG image files were not rendering inline in the Document Details page
36+ - Images were incorrectly loaded in iframes which caused browsers to download them instead of displaying
37+ - Added specific handling for image file types to use ` <img> ` tag instead of iframe
38+ - Images now display inline with responsive sizing (max-width: 100%, max-height: 800px)
39+ - Added error handling with fallback download link if image fails to load
40+ - Maintains consistent UI with other document types (PDF, Excel, Word)
3441
3542
3643## [ 0.3.7]
Original file line number Diff line number Diff line change @@ -239,6 +239,44 @@ const FileViewer = ({ objectKey }) => {
239239 </ Box >
240240 ) ;
241241 }
242+ // For image files, display them inline using img tag
243+ if ( fileType === 'image' ) {
244+ return (
245+ < Box className = "document-container" padding = { { top : 's' } } >
246+ < Box textAlign = "center" >
247+ < img
248+ src = { presignedUrl }
249+ alt = "Document preview"
250+ style = { {
251+ maxWidth : '100%' ,
252+ maxHeight : '800px' ,
253+ height : 'auto' ,
254+ objectFit : 'contain' ,
255+ } }
256+ onError = { ( e ) => {
257+ // On error, replace the image with a download link
258+ const container = e . target . parentElement ;
259+ container . innerHTML = `
260+ <div style="padding: 48px;">
261+ <h3>🖼️ Image Document</h3>
262+ <p>Unable to display this image.</p>
263+ <p>
264+ <a href="${ presignedUrl } " target="_blank" rel="noopener noreferrer"
265+ style="display: inline-block; padding: 12px 24px; background-color: #0073bb;
266+ color: white; text-decoration: none; border-radius: 4px;
267+ font-weight: bold; margin: 10px;">
268+ 📥 Download Image
269+ </a>
270+ </p>
271+ </div>
272+ ` ;
273+ } }
274+ />
275+ </ Box >
276+ </ Box >
277+ ) ;
278+ }
279+
242280 // For Excel and Docx files, provide download link since browsers can't display them inline
243281 if ( fileType === 'excel' || fileType === 'docx' ) {
244282 const fileTypeName = fileType === 'excel' ? 'Excel' : 'Word' ;
You can’t perform that action at this time.
0 commit comments