[ISSUE] v5.0.2 直接图片预览不显示文件名
Issue Type / 问题类型
Bug / 缺陷
kkFileView Version / kkFileView 版本
v5.0.2
Upstream commit: c4288f7e59b8d59d94a2f445ef759b657cde6543
Deployment Mode / 部署方式
Source build / Docker
Environment / 环境信息
- Linux container
- JDK 21
- Microsoft Edge / Google Chrome
- The reproduced build is pinned to the upstream
v5.0.2commit.picture.ftlandviewer.min.jsare unchanged from upstream.
Steps to Reproduce / 复现步骤
Start kkFileView
v5.0.2.Prepare any publicly accessible PNG image, for example:
https://www.w3.org/Icons/w3c_home.pngBase64-encode and URL-encode the image URL.
Open:
/onlinePreview?url=aHR0cHM6Ly93d3cudzMub3JnL0ljb25zL3czY19ob21lLnBuZw%3D%3DCheck the filename/title area in the Viewer.js image preview.
Compare the same image with kkFileView
v4.3.0.
Expected Result / 期望结果
The image is displayed and the Viewer.js title shows the decoded filename, for example w3c_home.png, consistent with v4.3.0.
Actual Result / 实际结果
The image loads and the normal viewing controls work, but the filename/title is empty.
Root Cause Analysis / 原因分析
In v4.3.0, picture.ftl uses a standard image element:
<li><img src="${img}" style="display: none"></li>Viewer.js derives the title from the DOM src property:
var src = image.src;
var alt = image.alt || getImageNameFromURL(src);Commit 7dc0469b30a0 changed the template element and the Viewer.js selector from img to div:
<li><div src="${finalUrl}" data-original-url="${finalUrl}" style="display: none"></li>Viewer.js can still load the image through the configured url: 'src' option and getAttribute('src'). However, HTMLDivElement has no standard src DOM property, so image.src is undefined and getImageNameFromURL(image.src) returns an empty string.
As of 2026-09-03, the master branch still uses <div src> without supplying a filename or alt value.
Suggested Fix / 建议修复方向
Before Viewer initialization, derive the filename from data-original-url and explicitly provide it to the Viewer title logic, or update the Viewer integration so title generation falls back to data-original-url / the configured URL attribute.
When a fetch proxy is enabled, the filename should be derived from data-original-url, not from a proxy URL such as getCorsFile?....
Logs & Screenshots / 日志与截图
No backend exception or browser console error is required to reproduce the issue. The image request and preview page both succeed; the failure is limited to title generation.
No screenshot is attached for now. The rendered HTML and the source comparison above reproduce the cause deterministically.
Sample File / 样例文件
Public sample: https://www.w3.org/Icons/w3c_home.png
Checklist / 提交前检查
- I searched existing issues and did not find a duplicate. / 我已搜索现有 Issue,未发现重复问题。
- I can reproduce this issue on the stated version/environment. / 我可在上述版本与环境复现该问题。
- The report contains no private deployment addresses, internal file URLs, credentials, or sensitive logs. / 本报告不包含私有部署地址、内部文件 URL、凭据或敏感日志。
ℹ️ This issue was prepared with assistance from ChatGPT Codex/GPT-5. The current client did not expose a session ID, 2026-09-03.
Source: kekingcn/kkFileView