Skip to content

fix: correct HEIC/HEIF/AVIF preview URL for local/FTP files#759

Open
guideuhome wants to merge 1 commit into
kekingcn:masterfrom
guideuhome:fix/issue-664-heic-preview-url
Open

fix: correct HEIC/HEIF/AVIF preview URL for local/FTP files#759
guideuhome wants to merge 1 commit into
kekingcn:masterfrom
guideuhome:fix/issue-664-heic-preview-url

Conversation

@guideuhome
Copy link
Copy Markdown

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:// or ftp:// URLs, PictureFilePreviewImpl was setting imgUrls to fileAttribute.getName() (just the filename). However, super.filePreviewHandle() downloads the file and stores the actual relative path in model.currentUrl. The heic.ftl template uses imgUrls to construct image URLs, so a bare filename would produce incorrect URLs like ${baseUrl}photo.heic instead of the correct downloaded file path.

Fix: Use model.getAttribute("currentUrl") — the actual downloaded file path — with a fallback to fileAttribute.getName() if currentUrl is null.

Enhancement: Add AVIF suffix routing

The wasm_heif.js decoder in static/heic/src/worker.js already supports AVIF decoding (it detects AVIF by checking array[8] == 0x61). FileType.java also already lists avif in PICTURE_TYPES. However, the suffix check in PictureFilePreviewImpl didn'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

  • HEIC/HEIF/AVIF files from HTTP URLs: unchanged, client-side WASM decoding via error handler
  • HEIC/HEIF/AVIF files from file:///FTP URLs: now correctly uses downloaded file path
  • AVIF files: now properly routed to heic.ftl template with WASM decoder

Closes #664

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

请求支持 heic 格式图片

1 participant