PHP code example of oscarotero / inline-svg
1. Go to this page and download the library: Download oscarotero/inline-svg library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
oscarotero / inline-svg example snippets
use InlineSvg\Collection;
use InlineSvg\Transformers\Cleaner;
$icons = Collection::fromPath('path/to/svg/files');
//Add a cleaner transformer to remove ids
$icons->addTransformer(new Cleaner());
//Insert the svg code of the file 'edit.svg':
echo $icons->get('edit'); // <svg ... </svg>
//Modify any attribute
echo $icons->get('edit')->withAttribute('class', 'big-icon'); // <svg class="big-icon" .. </svg>
//Make the svg accesible
echo $icons->get('edit')->withA11y('The edit icon'); // <svg role="img" aria-labelledby="icon-edit-123-title"><title id="icon-edit-123-title">The edit icon</title> .. </svg>