<svg> <defs> <g id="shape-icon-1"> <!-- all the paths and shapes and whatnot for this icon --> <g> <g id="shape-icon-2"> <!-- all the paths and shapes and whatnot for this icon --> <g> </defs> </svg> <!-- in use --> <svg class="icon" viewBox="214.7 0 182.6 792"> <use xlink:href="#shape-icon-1" /> </svg>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="beaker" viewBox="214.7 0 182.6 792"> <!-- <path>s and whatever other shapes in here --> </symbol> <symbol id="shape-icon-2" viewBox="0 26 100 48"> <!-- <path>s and whatever other shapes in here --> </symbol> </svg> <!-- in use --> <svg class="icon"> <use xlink:href="#shape-icon-1" /> </svg>
<?php echo file_get_contents("kiwi.svg"); ?>
gulp.task('svgicons', ['clean:svg'], function() { gulp.src(path.svg.src + '*.svg') .pipe(svgstore()) .pipe(gulp.dest(path.svg.dest)); });
gulp.task('svgicons', ['clean:svg'], function() { gulp.src(path.svg.src + '**/*.svg') .pipe(svgstore({inlineSvg: true})) .pipe(gulp.dest(path.svg.dest)); });
gulp.task('svgicons', ['clean:svg'], function() { gulp.src(path.svg.src + '**/*.svg') .pipe(rename({prefix: 'icon-'})) .pipe(svgstore({inlineSvg: true})) .pipe(gulp.dest(path.svg.dest)); });
gulp.task('svgicons', ['clean:svg'], function() { gulp.src(path.svg.src + '**/*.svg', { base: path.svg.src}) .pipe(rename(function (path) { var name = path.dirname.split(path.sep); name.push(path.basename); path.basename = name.join('-'); })) .pipe(svgstore({inlineSvg: true})) .pipe(gulp.dest(path.svg.dest)); });
gulp.task('svgicons', ['clean:svg'], function() { gulp.src(path.svg.src + '**/*.svg', { base: path.svg.src}) .pipe(rename(function (path) { var name = path.dirname.split(path.sep); name.push(path.basename); path.basename = name.join('-'); })) .pipe(imagemin()) .pipe(svgstore({inlineSvg: true})) .pipe(gulp.dest(path.svg.dest)); });
var minifySVGs = (function() { return gulp.src(path.svg.src + '**/*.svg', { base: path.svg.src}) .pipe(rename(function (path) { var name = path.dirname.split(path.sep); name.push(path.basename); path.basename = name.join('-'); })) .pipe(imagemin()); })(); gulp.task('svgicons', ['svgfallback'], function() { // svgstore minifySVGs .pipe(svgstore({inlineSvg: true})) .pipe(gulp.dest(path.svg.dest)); }); gulp.task('svgfallback', ['clean:svg'], function() { // svgfallback minifySVGs .pipe(svgfallback()) .pipe(gulp.dest(path.svg.dest)); });
Thanks for attention
<!-- 1 --> <symbol id="twitter"> <title>twitter</title> <path etc.../> </symbol> <!-- 2 --> <svg title="twitter"> <use xlink:href="map.svg#twitter"/> </svg> <!-- 3 --> <svg role="presentation"> <use xlink:href="map.svg#twitter"/> </svg> <!-- 4 --> <svg title="Find me on Twitter" role="img"> <use xlink:href="map.svg#twitter"/> </svg> <!-- 5 --> <svg title="send a mail" aria-labelledby="gmail-icon-title gmail-icon-desc"> <title id="gmail-icon-title">a icon of google mail</title> <desc id="gmail-icon-desc">send a mail to my Google mail</desc> <use xlink:href="map.svg#gmail"/> </svg>