# Icon

Whenever you're dealing with a icon in your template, you're actually working with a Icon object.

# Attributes

idID of the icon.
iconThe filename and relative path of the icon.
spriteThe filename and relative path of the icon. Set only if using SVG Sprites.
glyphIdSet only if using an Icon Font.
glyphNameSet only if using an Icon Font.
cssSet only if using an Remote Icon.
iconSetThe icon set this icon belongs to.
typeWhat type of icon this is: svg, sprite, glyph or css.
widthThe width of the icon.
heightThe height of the icon.
lengthReturn the string length of the icon for the field.
isEmptyReturns whether or not there's an icon selected for this field.

# Methods

getDimensions(height)Returns an array of [width, height] for the icon. Pass in an optional height to restrict it by, while keeping the aspect ratio of the icon.
getUrl()Return the full URL to the icon.
getPath()Return the full path to the icon.
getInline()Returns the raw contents of the icon.
getIconName()Returns the name of the icon, without the extension.
getGlyph(format)Returns the character representation of an individual icon glyph, for when an icon font is used.

# Glyph formats

getGlyph('decimal')Get the icon unicode (decimal).
getGlyph('hex')Get the icon unicode (hexadecimal).
getGlyph('char')Display the icon as html character - &#00000.
getGlyph('charHex')Display the icon as html character hex - &#xf100. Default

Get started with Icon Picker

Available for Craft 3. Get it from the plugin store.