All Projects → stevie-mayhew → silverstripe-svg

stevie-mayhew / silverstripe-svg

Licence: MIT license
Basic SVG support for SilverStripe

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to silverstripe-svg

silverstripe-singlepageadmin
Single page administration via a LeftAndMain like interface.
Stars: ✭ 24 (+9.09%)
Mutual labels:  silverstripe
silverstripe-cloudflare
This module aims to relieve the stress of using CloudFlare caching with any SilverStripe project. Adds extension hooks that clears CloudFlares cache for a specific page when that page is published or unpublished
Stars: ✭ 23 (+4.55%)
Mutual labels:  silverstripe
Silverstripe-SEO
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content
Stars: ✭ 41 (+86.36%)
Mutual labels:  silverstripe
silverstripe-base
A base module for my SilverStripe projects
Stars: ✭ 17 (-22.73%)
Mutual labels:  silverstripe
silverstripe-dashboard
Extendable dashboard for Silverstripe
Stars: ✭ 18 (-18.18%)
Mutual labels:  silverstripe
silverware-calendar
SilverWare Calendar Module
Stars: ✭ 15 (-31.82%)
Mutual labels:  silverstripe
cwp-watea-theme
A more visually appealing example for starting a theme for a CWP website.
Stars: ✭ 13 (-40.91%)
Mutual labels:  silverstripe
silverstripe-apiwesome
A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.
Stars: ✭ 13 (-40.91%)
Mutual labels:  silverstripe
silverstripe-cookie-consent
GDPR compliant cookie popup and consent checker
Stars: ✭ 16 (-27.27%)
Mutual labels:  silverstripe
silverstripe-mandrill
Mandrill integration for Silverstripe
Stars: ✭ 17 (-22.73%)
Mutual labels:  silverstripe
sliver
REPL for SilverStripe, powered by Psysh. Interactively debug and tinker with a sliver of your code.
Stars: ✭ 17 (-22.73%)
Mutual labels:  silverstripe
silverstripe-populate
Populate your database through YAML files
Stars: ✭ 23 (+4.55%)
Mutual labels:  silverstripe
silverstripe-smtp
Using PHPMailer in SilverStripe
Stars: ✭ 26 (+18.18%)
Mutual labels:  silverstripe
silverstripe-catalogmanager
Catalog administration via a LeftAndMain like interface. Lets you create and edit pages outside of the site tree
Stars: ✭ 36 (+63.64%)
Mutual labels:  silverstripe

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

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.

<!-- 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).

<!-- change width -->
{$SVG('name').width(200)}

<!-- change height -->
{$SVG('name').height(200)}

<!-- change size (width and height) -->
{$SVG('name').size(100,100)}

<!-- change fill -->
{$SVG('name').fill('#FF9933')}

<!-- change stroke -->
{$SVG('name').stroke('#FF9933')}

<!-- add class -->
{$SVG('name').extraClass('awesome-svg')}

<!-- specify a custom base path -->
{$SVG('name').customBasePath('assets/Uploads/SVG')}

<!-- specify a sub-folder of the base path (can be called multiple times) -->
{$SVG('name').addSubfolder('MyDir')}
{$SVG('name').addSubfolder('MyDir/MyOtherDir')}
{$SVG('name').addSubfolder('MyDir').addSubfolder('MyOtherDir')}

These options are also chainable.

{$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>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].