Repository navigation
fix(#787): show filename in image preview title via data-original-url - #798
Conversation
…e preview shows the filename (was empty for <div src>)
…e preview shows the filename (was empty for <div src>)
|
Pushed a fix after verifying the original approach against the bundled Root cause (confirmed by reading the source): the Fix: add |
klboke
left a comment
There was a problem hiding this comment.
Reviewed the latest head 86c2b8d, including the follow-up proxy fix.
The bundled Viewer rewrites data-original-url on its image clones, so copying that attribute through inheritedAttributes still showed getCorsFile when kkagent=true. The callback now reads the selected original element via this.images[this.index], retaining the original filename in both modes. I reproduced the previous failure and verified the corrected title in a real browser against the bundled Viewer.
Validation: PictureFilePreviewTests passes locally; the new browser E2E checks for direct and proxy image titles both pass. Linux/Windows/macOS packaging and the full PR E2E job are green on this exact head. No remaining blockers.
…the original URL
Verified against the bundled viewer.min.js: the `title(image, imageData)` callback
receives the <img> element Viewer.js creates internally (view(): `var image =
document.createElement('img')`), NOT the original <div>. Viewer only forwards the
attributes listed in `inheritedAttributes` (default: crossOrigin, decoding, isMap,
loading, referrerPolicy, sizes, srcset, useMap) when building that <img>, and
`data-original-url` is not in that list. So the previous title function always read
null and the title stayed 'image' -- the fix was a no-op at runtime.
Fix: add `data-original-url` to Viewer's `inheritedAttributes` so the original URL is
forwarded from the thumbnail <img> to the title <img>, letting
`getImageNameFromOriginalUrl` return the real filename (and not the CORS-proxy URL).
Also updates PictureFilePreviewTests to assert `inheritedAttributes` is configured
with data-original-url, locking the regression.
Fixes #787.
Direct image previews use hidden
<div src>elements, so Viewer's default title cannot obtain a filename from the DOMsrcproperty. Derive the title from the selected original element'sdata-original-url, stripping query/fragment parts before extracting the filename.The callback reads
this.images[this.index]: Viewer replacesdata-original-urlon its internal image clones with the actual fetch URL, which isgetCorsFile?...whenkkagent=true. Reading the original element preserves the source filename in both direct and proxy previews.Validation:
PictureFilePreviewTestspasses locally.photo.pngwithkkagent=falseandkkagent=true; the previous proxy case displayedgetCorsFile.picture-title.spec.tsto verify the rendered title through/onlinePreviewin both modes.