<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=TYPO3_-_Icon_API</id>
	<title>TYPO3 - Icon API - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=TYPO3_-_Icon_API"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=TYPO3_-_Icon_API&amp;action=history"/>
	<updated>2026-05-09T05:12:23Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=TYPO3_-_Icon_API&amp;diff=24373&amp;oldid=prev</id>
		<title>37.49.72.8: Die Seite wurde neu angelegt: „ https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Icon/Index.html  https://usetypo3.com/icon-api.html // Bessere Erklärung mit Beispi…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=TYPO3_-_Icon_API&amp;diff=24373&amp;oldid=prev"/>
		<updated>2020-02-06T10:57:40Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „ https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Icon/Index.html  https://usetypo3.com/icon-api.html // Bessere Erklärung mit Beispi…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt; https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Icon/Index.html&lt;br /&gt;
 https://usetypo3.com/icon-api.html // Bessere Erklärung mit Beispielen&lt;br /&gt;
&lt;br /&gt;
Registering an Icon&lt;br /&gt;
To use a custom icon in the TYPO3 backend we first have to register it in the class \TYPO3\CMS\Core\Imaging\IconRegistry. We call registerIcon() on an instance of that class to do so. We need to specify (at least) two things. The identifier of the icon and the name of the IconProvider class we want to use.&lt;br /&gt;
&lt;br /&gt;
The identifier is a unique string that identifies exactly one icon. Take whatever name you like. Prefix it with your extension name to be save and prevent naming conflicts.&lt;br /&gt;
The IconProvider is a class that generates the corect markup for a specific icon type. The core shipps three providers: BitmapIconProvider, SvgIconProvider and the FontawesomeIconProvider.&lt;br /&gt;
If you want to register a simple image file (jpg, gif, png) as an icon you go with the BitmapIconProvider.&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s look at an example.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);&lt;br /&gt;
$iconRegistry-&amp;gt;registerIcon(&lt;br /&gt;
  &amp;#039;tx-fs-code-snippet&amp;#039;,&lt;br /&gt;
  \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,&lt;br /&gt;
  [&amp;#039;source&amp;#039; =&amp;gt; &amp;#039;EXT:&amp;#039; . $extKey . &amp;#039;/Resources/Public/Images/code-snippet-icon.png&amp;#039;]&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
php&lt;br /&gt;
This code is best put into the ext_localconf.php. It registers an image (code-snippet-icon.png) with the identifier tx-fs-code-snippet. This identifier can now be used troughout the backend. But before we take a look at the usage let&amp;#039;s see how we use the FontawesomeIconProvider:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);&lt;br /&gt;
$iconRegistry-&amp;gt;registerIcon(&lt;br /&gt;
    &amp;#039;proof-of-concept&amp;#039;,&lt;br /&gt;
    \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider::class,&lt;br /&gt;
    [&lt;br /&gt;
        &amp;#039;name&amp;#039;     =&amp;gt; &amp;#039;spinner&amp;#039;,&lt;br /&gt;
        &amp;#039;spinning&amp;#039; =&amp;gt; true&lt;br /&gt;
    ]&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
php&lt;br /&gt;
If we use the BitmapIconProvider or the SvgIconProvider we have to specify the source of the icon while the FontawesomeIconProvider expects the name of the Font Awesome CSS class we want to use (but without the fa- prefix). All IconProviders however can take the additional option spinning to ... you guessed it ... make the icon spin.&lt;br /&gt;
&lt;br /&gt;
So much for registering an icon. But how do we use it?&lt;br /&gt;
&lt;br /&gt;
Top &lt;br /&gt;
&lt;br /&gt;
Using an Icon&lt;br /&gt;
There are many places in the core where we just need the identifier to render an icon. in the TCA for example you specify a new typeicon like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$GLOBALS[&amp;#039;TCA&amp;#039;][&amp;#039;tt_content&amp;#039;][&amp;#039;ctrl&amp;#039;][&amp;#039;typeicon_classes&amp;#039;][&amp;#039;fs_code_snippet&amp;#039;] = &amp;#039;tx-fs-code-snippet&amp;#039;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
php&lt;br /&gt;
But if we need our icon markup in our PHP code, we can always use an instance of  the \TYPO3\CMS\Core\Imaging\IconFactory. By passing our identifer to the method getIcon(), we get an instance of Icon. To modify the markup of the method Icon-&amp;gt;render(), we can optionally determine&lt;br /&gt;
&lt;br /&gt;
size (2nd argument) with the constants Icon::SIZE_SMALL (16px), Icon::SIZE_DEFAULT (32px) and Icon::SIZE_LARGE (48px),&lt;br /&gt;
an overlay icon (3rd argument) by its identifier and&lt;br /&gt;
the state of  the icon (4th argument) with the Enumeration constants IconState::STATE_DEFAULT and IconState::STATE_DISABLED. Note that the method expects an instance of the IconState class. So you have to cast the constant to such an instance: IconState::cast(IconState::STATE_DISABLED).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$iconFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconFactory::class);&lt;br /&gt;
$icon = $iconFactory-&amp;gt;getIcon(&lt;br /&gt;
  &amp;#039;tx-fs-code-snippet&amp;#039;,&lt;br /&gt;
  \TYPO3\CMS\Core\Imaging\Icon::SIZE_SMALL,&lt;br /&gt;
  &amp;#039;overlay-identifier&amp;#039;,&lt;br /&gt;
  \TYPO3\CMS\Core\Type\Icon\IconState::cast(\TYPO3\CMS\Core\Type\Icon\IconState::STATE_DISABLED)&lt;br /&gt;
);&lt;br /&gt;
$iconMarkup = $icon-&amp;gt;render();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
php&lt;br /&gt;
There also is a Fluid ViewHelper (\TYPO3\CMS\Core\ViewHelpers\IconViewHelper) that takes all these arguments as well and renders our icon within our Fluid template:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html5&amp;gt;&lt;br /&gt;
&amp;lt;html xmlns:core=&amp;quot;http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers&amp;quot; data-namespace-typo3-fluid=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;core:icon identifier=&amp;quot;tx-fs-code-snippet&amp;quot; size=&amp;quot;small&amp;quot; overlay=&amp;quot;overlay-identifier&amp;quot; state=&amp;quot;disabled&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
markup&lt;br /&gt;
And that is everything you need to know about the Icon-API of TYPO3.&lt;/div&gt;</summary>
		<author><name>37.49.72.8</name></author>
	</entry>
</feed>