Garry's Mod Wiki


DImage:SetImage( string strImage, string strBackup = "nil" )


Sets the image to load into the frame. If the first image can't be loaded and strBackup is set, that image will be loaded instead.

This eventually calls DImage:SetMaterial.


1 string strImage
The path of the image to load. When no file extension is supplied the VMT file extension is used.
2 string strBackup = "nil"
The path of the backup image.


Creates a frame with a map of de_inferno inside, with the default avatar image loaded as a backup.

-- Frame MainFrame = vgui.Create( "DFrame" ) MainFrame:SetSize( 300, 300 ) MainFrame:Center() MainFrame:SetTitle( "Map of de_inferno" ) -- Map of de_inferno (requires CS:S) local css_map = vgui.Create( "DImage", MainFrame ) css_map:SetPos( 25, 40 ) css_map:SetSize( 250, 250 ) -- Set image to de_inferno map -- If it can't be loaded, load the [?] avatar image instead css_map:SetImage("overviews/de_inferno", "vgui/avatar_default")
Output: If CS:S is mounted then the left image is shown, otherwise the right image is shown.

Page Links

Special Pages



Render Time: 62ms

DB GetPage 33
Generate Html 5
SaveChanges (1) 12
Render Body 0
Render Sidebar 9