ID:159557
 
I've been told that your icon files are already in the resource cache, so you do not need to use browse_rsc to display them.

My question is how do you use the < IMG > tag to display a specific icon? I do not want to /icon macro, because I am defining the HTML in a const var. I simply want to reference the icon file, and the icon state and I need to know the exact syntax to do this.
You can't browse() them, because browse() uses Internet Explorer to display the HTML. It does seem to display .dmi files, but not icon states.
For a .dmi file with only one icon state, just use
<img src="myfile.dmi" style="width: 32px; height: 32px;">

in your html.
If you want one state from a file, you need to create an /icon object with that state, browse_rsc() it (with a file name; that will create a file in the resource cache with just that state that the client can access) and display it as above.
In response to Immibis
It seems kind of ridiculous to me that you can't display specific iconstates. In the example code for the /icon text macro, it uses the ICONSTATE img tag attribute, but I have never been able to get it to work.

even the entry in Tags (text) for is

//display icons


So one would think that you'd be able to use it to display icons...
In response to GauHelldragon
It works in the output, ie src << "text..." or world << "text..."
But not in browse() because Internet Explorer doesn't understand ICONSTATE.
In response to Immibis
Hm. Fair enough. I ended up using regular image files instead of trying to use the ingame icons.
In response to GauHelldragon
client/proc/browse_rsc_icon(icon, icon_state)
var/icon/i = new(icon, icon_state)
src << browse_rsc(i, "[icon]_[icon_state].png") // dmi files are just png files with the extension .dmi, using .png may make this more compatible with different versions of IE

Call browse_rsc_icon with an icon and icon state to send that icon state to the client.
To display an icon (after using browse_rsc_icon):
<img src="[icon]_[icon_state].png" style="width: 32px; height: 32px;">