Skip to content
A jQuery plugin to replace <image> and <object> embed SVG inline.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
dist
spec
src
tasks
.bowerrc
.csslintrc
.editorconfig
.eslintrc
.gitattributes
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
bower.json
config.json
gulpfile.js
karma.conf.js
package-lock.json
package.json

README.md

jQuery SVG to inline Open Source Love

LIKED ? Leave a : 😞

Release Downloads License Build Status Coverage Status Dependencies Status devDependencies Status

A jQuery plugin to replace <image> and <object> embed SVG inline.

Table of Contents

Examples

<object type="image/svg+xml" data="htts://somesvg.svg" class="svg"></object>

<img src="https://somesvg.svg" class="svg">

Will be replaced by the linked SVG

<!-- Replaces <object> -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <circle cx="50" cy="50" r="50"/>
</svg>

<!-- Replaces <img> -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <rect x="50" y="20" width="150" height="150" />
</svg>

Getting Started

npm install jquery-svg-to-inline

Usage

$('.svg').svgToInline()

Options

useTriggerClass

By default the trigger class isn't used on inline svg. If you want to use it, set it to true.

$('.svg').svgToInline({useTriggerClass: true})
Example
<img src="https://somesvg.svg" class="svg">

Will generate

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" class="svg">
  <circle cx="50" cy="50" r="50"/>
</svg>

License

jQuery SVG to inline is released under the terms of the MIT license.

You can’t perform that action at this time.