Basic SVG support for SilverStripe
SilverStripe 4 or higher
composer require magnum34/silverstripe-svg-go
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')
SVGField
MIT license. See the LICENSE file for more details.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem