@@ -30,6 +30,8 @@ class Avatar
30
30
31
31
protected int $ height ;
32
32
33
+ protected bool $ responsive = false ;
34
+
33
35
protected array $ availableBackgrounds = [];
34
36
35
37
protected array $ availableForegrounds = [];
@@ -134,6 +136,7 @@ public function applyTheme(array $config): void
134
136
$ this ->fontSize = $ config ['fontSize ' ];
135
137
$ this ->width = $ config ['width ' ];
136
138
$ this ->height = $ config ['height ' ];
139
+ $ this ->responsive = $ config ['responsive ' ];
137
140
$ this ->ascii = $ config ['ascii ' ];
138
141
$ this ->uppercase = $ config ['uppercase ' ];
139
142
$ this ->rtl = $ config ['rtl ' ];
@@ -210,7 +213,11 @@ public function toSvg(): string
210
213
$ radius = ($ this ->width - $ this ->borderSize ) / 2 ;
211
214
$ center = $ this ->width / 2 ;
212
215
213
- $ svg = '<svg xmlns="http://www.w3.org/2000/svg" width=" ' .$ this ->width .'" height=" ' .$ this ->height .'" viewBox="0 0 ' .$ this ->width .' ' .$ this ->height .'"> ' ;
216
+ $ svg = '<svg xmlns="http://www.w3.org/2000/svg" ' ;
217
+ if (! $ this ->responsive ) {
218
+ $ svg .= ' width=" ' .$ this ->width .'" height=" ' .$ this ->height .'" ' ;
219
+ }
220
+ $ svg .= ' viewBox="0 0 ' .$ this ->width .' ' .$ this ->height .'"> ' ;
214
221
215
222
if ($ this ->shape === 'square ' ) {
216
223
$ svg .= '<rect x=" ' .$ x
@@ -455,6 +462,7 @@ protected function validateConfig(array $config): array
455
462
'fontSize ' => 48 ,
456
463
'width ' => 100 ,
457
464
'height ' => 100 ,
465
+ 'responsive ' => false ,
458
466
'ascii ' => false ,
459
467
'uppercase ' => false ,
460
468
'rtl ' => false ,
0 commit comments