2017 © Pedro Peláez
 

silverstripe-vendormodule silverstripe-svg

Basic SVG support for SilverStripe

image

stevie-mayhew/silverstripe-svg

Basic SVG support for SilverStripe

  • Friday, October 20, 2017
  • by stevie-mayhew
  • Repository
  • 2 Watchers
  • 17 Stars
  • 26,283 Installations
  • PHP
  • 5 Dependents
  • 1 Suggesters
  • 5 Forks
  • 2 Open issues
  • 14 Versions
  • 8 % Grown

The README.md

SilverStripe SVG

Basic SVG support for SilverStripe templates, (*1)

Requirements

SilverStripe 4 or higher, (*2)

Installation

composer require stevie-mayhew/silverstripe-svg, (*3)

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, (*4)

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., (*5)

<!-- add svg -->
{$SVG('name')}
<!-- add svg with id 'testid' -->
{$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)., (*6)


{$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., (*7)

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

Example Output

<svg xmlns="http://www.w3.org/2000/svg" viewBox="248.5 0 464.8 560" enable-background="new 248.5 0 464.8 560" class="svg-name"><path d="M550.9 0H248.5v560h464.8V154.9L550.9 0zM648 149.3H534.1V41.1L648 149.3zm22.4 369.6H289.6V41.1h205.3v149.3h177.3v328.5h-1.8zM343.7 272.5h272.5v41.1H343.7zM343.7 369.6h272.5v41.1H343.7z"></path></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="248.5 0 464.8 560" enable-background="new 248.5 0 464.8 560" class="svg-with-id svg-test-id" id="test-id"><path d="M550.9 0H248.5v560h464.8V154.9L550.9 0zM648 149.3H534.1V41.1L648 149.3zm22.4 369.6H289.6V41.1h205.3v149.3h177.3v328.5h-1.8zM343.7 272.5h272.5v41.1H343.7zM343.7 369.6h272.5v41.1H343.7z"></path></svg>

The Versions

20/10 2017

dev-master

9999999-dev

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

20/10 2017

2.1.0

2.1.0.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

10/10 2017

2.0.1

2.0.1.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

23/08 2017

2.0.0

2.0.0.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

01/06 2016

1.2.0

1.2.0.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

01/06 2016

1.0.x-dev

1.0.9999999.9999999-dev

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

16/12 2015

1.1.1

1.1.1.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

08/10 2015

1.1.0

1.1.0.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

17/06 2015

1.0.4

1.0.4.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

04/02 2015

1.0.3

1.0.3.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

04/02 2015

dev-stevie-mayhew-patch-1

dev-stevie-mayhew-patch-1

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

23/11 2014

1.0.2

1.0.2.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

 

template silverstripe svg

23/11 2014

1.0.1

1.0.1.0

Basic SVG support for SilverStripe

  Sources   Download

MIT

The Requires

  • silverstripe-framework ~3.1

 

template silverstripe svg

23/11 2014

1.0.0

1.0.0.0

Basic SVG support for SilverStripe

  Sources   Download

The Requires

  • silverstripe-framework ~3.1

 

template silverstripe svg