Image Loading and HtmlTagSrcHook
Estimated reading time: 2 minutesModLoader intercepts image requests via HtmlTagSrcHook so images can be loaded from Mod zips without a server.
How It Works
Since v1.6.0, ModLoader hooks into SC2's Wikifier.Parser.add 'htmlTag' to intercept image creation:
All HTML <img> tags created by SC2 can now be intercepted and replaced. Previously, only canvas-drawn images were handled.
Sync Path: Intercept HTMLImageElement
If you have an HTMLImageElement, you can let ModLoader handle its src:
Async Path: Direct Image Request
Pass an image path and receive a Promise:
Using ImageLoaderHook Addon
For most Mod authors, use the ImageLoaderHook Addon (v2.3.0+), which wraps HtmlTagSrcHook. Add images to boot.json's imgFileList; images matching the base game are replaced automatically.
Some DoL images are not intercepted—they are created by DoL's custom Macro.add("icon", ...) and mostly used before links.
