How to get item icon name

HI all, in these days I’m trying to understand the algorithm that WoWHead and OpenWoW use to get the icon of an item (or an achievements etc.) anyone know how to obtain that?

the icon name should be like this “inv_fabric_purplefire_o01” (

EDIT: I did with this

openwow probably uses the DBC data (see itemdisplayinfo.dbc)
wowhead on the other hand maybe uses methods like and or they get the info by reading the UI data from client addons if they cant read / extract the DBC files for some (legal?) reasons.

For example if an achievement shows in the UI, we can access that UI element and read what the texture path is.