🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

svg-to-inline is a small jQuery plugin that convert SVG files embedded using object and img into inline SVG using SVG tag.

SVG

Documentation

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 May Also Like