Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stevie-mayhew/silverstripe-svg

Basic SVG support for SilverStripe
https://github.com/stevie-mayhew/silverstripe-svg

php silverstripe svg svg-support

Last synced: 17 days ago
JSON representation

Basic SVG support for SilverStripe

Awesome Lists containing this project

README

        

# SilverStripe SVG

Basic SVG support for SilverStripe templates

## Requirements
SilverStripe 4 or higher

## Installation
```composer require stevie-mayhew/silverstripe-svg```

## Configuration

You can set the base path for where your SVG's are stored. You can also add extra default classes to the SVG output

```yml
StevieMayhew\SilverStripeSVG\SVGTemplate:
base_path: 'themes/base/production/svg/'
default_extra_classes:
- 'svg-image'
```

## Usage
In a SilverStripe template simply call the SVG template helper.

```html

{$SVG('name')}

{$SVG('with-id', 'testid')}
```

There also helper functions for width, height, size, fill, adding extra classes, setting a custom/alternative base path and specifying a sub-folder within the base path (for those who want to categories and folder off your images).
```html

{$SVG('name').width(200)}

{$SVG('name').height(200)}

{$SVG('name').size(100,100)}

{$SVG('name').fill('#FF9933')}

{$SVG('name').stroke('#FF9933')}

{$SVG('name').extraClass('awesome-svg')}

{$SVG('name').customBasePath('assets/Uploads/SVG')}

{$SVG('name').addSubfolder('MyDir')}
{$SVG('name').addSubfolder('MyDir/MyOtherDir')}
{$SVG('name').addSubfolder('MyDir').addSubfolder('MyOtherDir')}

```

These options are also chainable.

```html
{$SVG('name').fill('#45FABD').width(200).height(100).extraClass('awesome-svg').customBasePath('assets/Uploads/SVG').addSubfolder('MyDir')}
```

### Example Output
```html

```