
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
jquery-inline-svg
Advanced tools
Takes an <img>
with an SVG as its source and replace it with an inline <svg>
so you can manipulate the style of it with CSS/JS etc.
npm install jquery-inline-svg
Download the dist/jquery-inline-svg.min.js and add it to your project.
<!-- Add some SVG `<img>` tags. -->
<img src="image-one.svg" data-inline-svg>
<img src="image-two.svg" data-inline-svg>
<!-- Include the `jquery-inline-svg` script on your page after `jQuery`. -->
<script src="jquery.min.js"></script>
<script src="jquery-inline-svg.min.js"></script>
<!-- Inline images. -->
<script>
$('[data-inline-svg]').inlineSvg();
</script>
<!-- The `<img>` tags have now been replaced with the full SVG markup. -->
Or with ES2015 modules
import $ from 'jquery';
import 'jquery-inline-svg';
$('[data-inline-svg]').inlineSvg();
svgInlined
event will be fired on every <img>
with inlined SVG element as argument
$('[data-inline-svg]').on('svgInlined', function (e, svgElement) {
const $originalImage = $(this); // <-- original <img> will be removed from the DOM when this event handler function finished
const $inlinedSvgElement = $(svgElement).addClass('is-loaded');
})
This plugin requires jQuery 3
Inspired by inlineSvg from UIkit 2 https://github.com/uikit/uikit/blob/v2/master/src/js/core/utility.js#L267
1.0.2 - 2019-03-01
FAQs
Replace SVG images with inline SVG element
We found that jquery-inline-svg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.