fix: correct HEIC/HEIF/AVIF preview URL for local/FTP files#759
Open
guideuhome wants to merge 1 commit into
Open
fix: correct HEIC/HEIF/AVIF preview URL for local/FTP files#759guideuhome wants to merge 1 commit into
guideuhome wants to merge 1 commit into
Conversation
- Use currentUrl from model instead of fileAttribute.getName() for file/ftp URLs. After super.filePreviewHandle() downloads the file, the actual path is stored as currentUrl in the model. Using just the filename causes the heic.ftl template to construct incorrect image URLs. - Add avif suffix to HEIC template routing. The wasm_heif.js decoder in static/heic/src/worker.js already supports AVIF decoding, and FileType.java already lists avif in PICTURE_TYPES. This ensures AVIF files also benefit from client-side conversion. Closes kekingcn#664
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
Fixes two issues in HEIC/HEIF/AVIF file preview implementation:
Bug Fix: Wrong URL for local/FTP files
When previewing HEIC/HEIF/AVIF files from
file://orftp://URLs,PictureFilePreviewImplwas settingimgUrlstofileAttribute.getName()(just the filename). However,super.filePreviewHandle()downloads the file and stores the actual relative path inmodel.currentUrl. Theheic.ftltemplate usesimgUrlsto construct image URLs, so a bare filename would produce incorrect URLs like${baseUrl}photo.heicinstead of the correct downloaded file path.Fix: Use
model.getAttribute("currentUrl")— the actual downloaded file path — with a fallback tofileAttribute.getName()ifcurrentUrlis null.Enhancement: Add AVIF suffix routing
The
wasm_heif.jsdecoder instatic/heic/src/worker.jsalready supports AVIF decoding (it detects AVIF by checkingarray[8] == 0x61).FileType.javaalso already listsavifinPICTURE_TYPES. However, the suffix check inPictureFilePreviewImpldidn't route AVIF to the HEIC template, causing AVIF files to use the generic picture template without client-side conversion support.Fix: Add
suffix.equalsIgnoreCase("avif")to the HEIC template routing condition.Testing
Closes #664