1
1
# Font Awesome SVG - PHP
2
2
3
- A PHP class that can be used to add [ Font Awesome 5 +] ( https://fontawesome.com/ ) 's SVG icons inline without Javascript.
3
+ A PHP class that can be used to add [ Font Awesome 6 +] ( https://fontawesome.com/ ) 's SVG icons inline without Javascript.
4
4
5
5
## Installation
6
6
@@ -26,37 +26,37 @@ Or you can download the `FontAwesomeSVG.php` file and include it manually.
26
26
// $dir = directory where SVG files are
27
27
$FA = new FontAwesomeSVG($dir);
28
28
29
- echo $FA->get_svg('fas fa-file');
29
+ echo $FA->get_svg('fa-solid fa-file');
30
30
```
31
31
32
32
Add custom classes:
33
33
34
34
``` php
35
- echo $FA->get_svg('fas fa-file', ['class' => 'my-custom-class another-class']);
35
+ echo $FA->get_svg('fa-solid fa-file', ['class' => 'my-custom-class another-class']);
36
36
```
37
37
38
38
Remove default class ` .svg-inline--fa ` :
39
39
40
40
``` php
41
- echo $FA->get_svg('fas fa-file', ['default_class' => false]);
41
+ echo $FA->get_svg('fa-solid fa-file', ['default_class' => false]);
42
42
```
43
43
44
44
Change ` <path> ` fill (default is ` currentColor ` ):
45
45
46
46
``` php
47
- echo $FA->get_svg('fas fa-file', ['fill' => '#f44336']);
47
+ echo $FA->get_svg('fa-solid fa-file', ['fill' => '#f44336']);
48
48
```
49
49
50
50
Add ` <title></title> ` :
51
51
52
52
``` php
53
- echo $FA->get_svg('fas fa-file', ['title' => 'My accessible icon']);
53
+ echo $FA->get_svg('fa-solid fa-file', ['title' => 'My accessible icon']);
54
54
```
55
55
56
56
Multiple options at once:
57
57
58
58
``` php
59
- echo $FA->get_svg('fas fa-file', [
59
+ echo $FA->get_svg('fa-solid fa-file', [
60
60
'class' => 'my-custom-class another-class',
61
61
'default_class' => false,
62
62
'title' => 'My title',
@@ -68,7 +68,7 @@ echo $FA->get_svg('fas fa-file', [
68
68
Customise duotone icons:
69
69
70
70
``` php
71
- echo $FA->get_svg('fad fa-laugh-wink', [
71
+ echo $FA->get_svg('fa-duotone fa-laugh-wink', [
72
72
'primary' => [
73
73
'fill' => '#e64980',
74
74
],
@@ -95,6 +95,16 @@ echo $FA->get_svg('fad fa-laugh-wink', [
95
95
96
96
> Requires ** v5.10.0** or greater, and a FontAwesome Pro license
97
97
98
+ ## Sharp
99
+
100
+ > Requires ** v6.4.0** or greater, and a FontAwesome Pro license
101
+
102
+ ``` php
103
+ echo $FA->get_svg('fa-sharp fa-light fa-file');
104
+ echo $FA->get_svg('fa-sharp fa-regular fa-file');
105
+ echo $FA->get_svg('fa-sharp fa-solid fa-file');
106
+ ```
107
+
98
108
### options
99
109
100
110
If ` inline_style ` is enabled, the value of ` fill ` and ` opacity ` are also used in the inline style on ` <svg> ` tag.
@@ -149,6 +159,24 @@ echo $FA->get_svg('fad fa-laugh-wink', [
149
159
]);
150
160
```
151
161
162
+ ## Aliases
163
+
164
+ The short aliases from version 5 are still supported
165
+
166
+ ``` php
167
+ echo $FA->get_svg('fab fa-twitter');
168
+ echo $FA->get_svg('fad fa-file');
169
+ echo $FA->get_svg('fal fa-file');
170
+ echo $FA->get_svg('far fa-file');
171
+ echo $FA->get_svg('fas fa-file');
172
+
173
+ // And the new shorthands for thin and sharp
174
+ echo $FA->get_svg('fat fa-file'); // thin
175
+ echo $FA->get_svg('fasl fa-file'); // sharp-light
176
+ echo $FA->get_svg('fasr fa-file'); // sharp-regular
177
+ echo $FA->get_svg('fass fa-file'); // sharp-solid
178
+ ```
179
+
152
180
## Accessibility
153
181
154
182
The below is implemented based on:
@@ -169,7 +197,7 @@ The below is implemented based on:
169
197
You can set a ` <title> ` , an ` id ` for the ` <title> ` and the ` aria-labelledby ` attribute will be added automatically:
170
198
171
199
``` php
172
- echo $FA->get_svg('fas fa-file', [
200
+ echo $FA->get_svg('fa-solid fa-file', [
173
201
'title' => 'File',
174
202
'title_id' => 'file-id',
175
203
]);
@@ -186,7 +214,7 @@ echo $FA->get_svg('fas fa-file', [
186
214
You can add any aria-\* attribute to the SVG tag:
187
215
188
216
``` php
189
- echo $FA->get_svg('fas fa-file', [
217
+ echo $FA->get_svg('fa-solid fa-file', [
190
218
'aria-label' => 'File',
191
219
]);
192
220
```
@@ -200,7 +228,7 @@ echo $FA->get_svg('fas fa-file', [
200
228
` aria-hidden="true" ` is added to the SVG tag by default unless ` <title id=""> ` (and ` aria-labelledby ` ) or ` aria-label ` is set.
201
229
202
230
``` php
203
- echo $FA->get_svg('fas fa-file');
231
+ echo $FA->get_svg('fa-solid fa-file');
204
232
```
205
233
206
234
``` html
0 commit comments