-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"custom-location to PNG fallback" again #135
Comments
@ganlanyuan have you tried the following stated in the
if you put an attribute denoting background color on the svg element, you can programmatically switch the fallback image. |
I'm using the fallback function. But still don't know how to switch.
|
@ganlanyuan fallback needs to return the path to the png image that you want the svg to fallback to. If 'data-fallback' contains that path, that should work. If not, let me know and I can try to debug. |
Great! Thanks! How about dynamic png? |
The PR you linked is dynamic SVG, not dynamic PNG, so it won't actually solve your problem (and TBH, I don't see the use case for this). Ofc, its up to the maintainers to decide whether to review & merge that PR or not :) Glad you resolved your issue! |
I see, thanks a lot for your help! |
@ganlanyuan could you please post your html/svg markup here? Since i am using svg4everybody in combination with Vivus i am trying to incet the data attribute dynamically into the the markup. Here is my approach: `
); |
Hey, I was using it this way: svg4everybody({
polyfill: true,
fallback: function (src, svg, use) {
// src: current xlink:href String
// svg: current SVG Element
// use: current USE Element
var path = use.getAttribute('data-fallback');
if (path) {
return 'assets/svg/fallback/' + path + '.png';
} else {
return src.replace('sprites.svg#', 'fallback/') + '.png';
}
}
}); Markup <!-- default fallback png -->
<svg role="img" title="right arrow" width="14" height="14"><use xlink:href="assets/svg/sprites.svg#rightangle90" /></svg>
<!-- special fallback png -->
<svg role="img" title="submit" width="48" height="48"><use xlink:href="assets/svg/sprites.svg#rightarrow-line" data-fallback="rightarrow-line-white" /></svg> Svg is just a svg-sprites file, nothing special. |
how do I test that the fallback code? which browser do I need to load this code on to test it. |
Hey,
I have read #14, #19, #34, but still not clear what's going on with this feature?
Consider I have the same svg file, but different fallback png images based on background-color.
How can I approach this?
Can you add support to custom-attribute like #19? Then we can change our fallback png very easily.
Also very interested in dynamic png fallback. An example usage is changing the fallback image on mouse over.
The text was updated successfully, but these errors were encountered: