You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-2Lines changed: 18 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -43,8 +43,24 @@ You can also use named arguments if you prefer a leaner syntax. Be aware, that t
43
43
) ?>>
44
44
```
45
45
46
-
⚠️ If you need XML-compatible attributes, always call `$attributes->toXml()` instead of just echoing the `Attributes` object,
47
-
because otherwise all attributes will be converted to lower-case.
46
+
Or if all you have is an attributes string, you can also feed the that to the `attributes()` helper:
47
+
48
+
```php
49
+
<?php
50
+
51
+
// get image dimensions as height="yyy" width="xxx"
52
+
$src = 'img.png';
53
+
$size = getimagesize($src)[3];
54
+
55
+
?>
56
+
57
+
<img <?= attributes($size)->merge([
58
+
'src' => $src,
59
+
'alt' => '',
60
+
]) ?>>
61
+
```
62
+
63
+
⚠️ If you need XML-compatible attributes, always call `$attributes->toXml()` instead of just echoing the `Attributes` object, because otherwise all attributes will be converted to lower-case.
48
64
49
65
In many cases, you need to set different classes. The `classes()` helper is a nice shortcut for improved readability:
0 commit comments