diff --git a/services-helpers.md b/services-helpers.md index b4c63f00..a2730e2a 100644 --- a/services-helpers.md +++ b/services-helpers.md @@ -77,6 +77,12 @@ Winter includes a variety of "helper" PHP functions. Many of these functions are [trans_choice](#method-trans-choice) +### SVG + +
+[extract](#method-svg-extract) +
+ ### Miscellaneous
@@ -763,6 +769,28 @@ The `trans_choice` function translates the given language line with inflection: $value = trans_choice('foo.bar', $count); ``` + +## SVG + +Winter includes a simple SVG utility that allows you to extract sanitized SVG markup from a given path. This can be +useful for sanitization, or for using SVG markup directly in your themes. + + +#### `Svg::extract()` {#collection-method} + +The `extract` method allows you to extract the sanitized SVG markup in a given path. Sanitization prevents the use of +JavaScript, remote sources and CSS imports, stopping common attack vectors within SVG code. + +```php +$svg = Svg::extract('/path/to/image.svg'); +``` + +By default, the output SVG markup is minified. The second parameter allows you to disable this by setting it to `false`. + +```php +$minifiedSvg = Svg::extract('/path/to/image.svg', false); +``` + ## Miscellaneous