feat(media): Add Copy URL to Media Browser context menu#16893
feat(media): Add Copy URL to Media Browser context menu#16893Ibochkarev wants to merge 2 commits intomodxcms:3.xfrom
Conversation
- Add urlExternal and urlAbsolute to file list for Media Browser - Add Copy URL menu item for files with viewable URL - Extract copyToClipboard to MODx.util for reuse - Use Clipboard API with execCommand fallback - Fix phpcs line length in modified methods Resolves modxcms#13618
Code ReviewSummary Adds a "Copy URL" option to the Media Browser and File Tree context menus. Backend changes add Suggestions
Assessment Well-structured multi-file change. The Verdict: Approve |
What does it do?
Adds a "Copy URL" option to the Media Browser and File Tree context menus. Users can right-click a file and copy its absolute URL to the clipboard. The feature uses
urlExternalorurlAbsolutewhen available, falling back tofullRelativeUrlorurl.Backend changes:
modMediaSourceandmodS3MediaSource: addurlExternalandurlAbsoluteto file list data, pass$file_listtogetListFileContextMenugetListFileContextMenu: add Copy URL menu item when file has a viewable URL; show for public files next to Copy Path, for private files as a separate itemFrontend changes:
copyToClipboardtoMODx.util.copyToClipboardinutilities.js(removes duplication)execCommandfallback for older/non-HTTPS contextscopyUrlhandler inmodx.browser.jsandmodx.tree.directory.jsWhy is it needed?
Users need to quickly copy file URLs for sharing or embedding. Previously only Copy Path (relative path) was available.
How to test
Related issue(s)/PR(s)
Resolves #13618