jonnyhaynes / inline-svg Goto Github PK
View Code? Open in Web Editor NEWTakes an inline image with an SVG as it's source and swaps it for an inline SVG
License: MIT License
Takes an inline image with an SVG as it's source and swaps it for an inline SVG
License: MIT License
Your code copies the content of the longdesc
attribute into the desc
element.
However, the longdesc
attribute shall contain "A link to a more detailed description of the image. Possible values are a URL or an element id" (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes:~:text=CSS%20property%20instead.-,longdesc,-Deprecated), while "The desc
element provides an accessible, long-text description of any SVG" (https://developer.mozilla.org/en-US/docs/Web/SVG/Element/desc).
Completely different kind of content. The longdesc
attribute is a link, not a text.
If I use your plugin like this:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="/node_modules/inline-svg/dist/inlineSVG.min.js"></script>
<script>
inlineSVG.init({
svgSelector: 'img.svg', // the class attached to all images that should be inlined
initClass: 'js-inlinesvg', // class added to <html>
storeResults: false // should the results be stored in localStorage
}, callback);
</script>
I receive:
Uncaught ReferenceError: callback is not defined
Why? If I remove the callback it works. Is this really needed?
We're not currently creating asynchronous requests which could cause issues on some projects.
If we are convert two svg images having same classes. One having embedded style tag then other svg also using the same styles that are used in first svg image.
aria-labelledby
should point to an ID, but instead it is pointing to the title
tag. This leads to a broken aria reference.
Additionally, aria-labelledby
shouldn't be added if no alt
attribute is present. Can consider adding role="presentation"
and aria-hidden="true"
in cases where no alt
is present. As this tells screen readers to ignore it, similar to when an empty alt
is present on img
tags
The README suggests specifying this version in bower.json, and, though it's been updated in your bower.json, the repository hasn't been tagged. bower install
outputs:
bower inline-svg#2.2.3 ENORESTARGET No tag found that was able to satisfy 2.2.3
Additional error details:
Available versions in https://github.com/jonnyhaynes/inline-svg.git: 2.2.1, 2.2.0, 2.1.5, 2.1.4, 2.1.3, 2.1.2, 2.1.1, 2.1.0, 2.0.1, 2.0.0, 1.2.0, 1.0.5, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0
If the <svg>
tag in the image being loaded has a class, this will be overridden when the SVG is inlined:
<svg class="someclass" xmlns="http://www.w3.org/2000/svg" width="53" height="27" viewBox="0 0 53 27">
<circle cx="26.5" cy="13.5" r="8" fill="#FFF" fill-rule="evenodd" />
</svg>
<svg class="someclass svg inlined-svg" xmlns="http://www.w3.org/2000/svg" width="53" height="27" viewBox="0 0 53 27">
<circle cx="26.5" cy="13.5" r="8" fill="#FFF" fill-rule="evenodd" />
</svg>
<svg class="svg inlined-svg" xmlns="http://www.w3.org/2000/svg" width="53" height="27" viewBox="0 0 53 27">
<circle cx="26.5" cy="13.5" r="8" fill="#FFF" fill-rule="evenodd" />
</svg>
I know as a workaround I can define the class in the <img>
tag and it'll be retained, but this seems redundant/inconvenient.
Hello!
I am trying to find a solution to allow inline insertion of SVG graphics which are stored on a AWS S3 process. I am able to get inline-svg working but if my img tag refers to the AWS URL then the SVG is not inserted inline, its left as an image tag (the svg is visible, just not inline). Is there any way to get inline-svg.js to work with files stored on AWS?
We should probably look to make this an AMD compatible module.
This is due to the main
field pointing to inlineSVG.js
in the root of the project.
I'm having some errors while using this library. It seems to be working anyways so far.
Cannot read property 'removeAttribute' of undefined
Line 121
inlinedSVG = result.getElementsByTagName('svg')[0];
// Remove some of the attributes that aren't needed
inlinedSVG.removeAttribute('xmlns:a');
There should be a check if( inlinedSVG ) actually exists.
The older jQuery code had the ability to add in an aria-label
and title
attribute to the resulting SVG, the new non-jQuery version doesn't currently add in the title
attribute as per the W3C spec.
It appears as if the callback never actually fires, utilizing the following syntax:
inlineSVG.init({
svgSelector: INLINE_SVG_OPTIONS.selector,
initClass: INLINE_SVG_OPTIONS.initClass,
}, () => {
console.log('ever getting here?');
});
Thoughts on this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.