magnum34/silverstripe-svg-go

Basic SVG Image Support

Installs: 75

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 1

Open Issues: 1

Type:silverstripe-module

dev-master 2019-07-28 02:00 UTC

This package is auto-updated.

Last update: 2024-05-28 12:06:20 UTC


README

Build Status Scrutinizer Code Quality SilverStripe supported module

Basic SVG support for SilverStripe

Requirements

SilverStripe 4 or higher

Installation

composer require magnum34/silverstripe-svg-go

Usage

use Magnum34\SilverStripeSVGGO\Models\IconSVG

class CustomPage extends Page {
    
    
    private static $many_many = [
        'Icon' => IconSVG::class
    ];
    
    public function getCMSFields()
    {
        $fields =  parent::getCMSFields();
        $select = AjaxSelect2Field::create('IconID','Icon');
        $select->setConfig('multiple',false);
        $select->setConfig('resultsFormat', '<strong>$Title</strong><br />$Thumbnail');
        $select->setConfig('classToSearch', IconSVG::class);
        $select->setConfig('minimumInputLength', 0);
        $select->setConfig('placeholder', 'Search for a Icon...');
        $select->setConfig('selectionFormat', '<strong>$Title </strong>');
        $fields->addFieldToTab('Root.Icon',$select);
        $fields->addFieldToTab('Root.Icon',
                    HasOneButtonField::create($this, 'Icon',"Icon",'Icon (only .svg, .png, .jpg, .jpeg)'),
                    'Content');
        
        
        
        return $fields;
        
    }

}

for Template

$Icon

Adding custom class to SVG or image

$Icon.setCSSClass('test')

TODO

SVGField

License

MIT license. See the LICENSE file for more details.