-
AuthorPosts
-
August 16, 2016 at 12:45 pm #673170
Hi
I am using SVG files on my site and want to set a png fallback for browsers like IE8. I saw on this thread: https://kriesi.at/support/topic/svg-graphic-as-logo-and-fallback-png/
That the following code below was recommended to put in the functions.php. I tried putting it in my child theme functions but it broke. I am not so familiar with PHP. Please can you let me know exactly what I should place in my functions file for it to work. Seems the extra php tags are breaking it.. Many thanks
function svg_replace(){
?>
<script>
(function($){
$(window).load(function(){
$(‘img[src$=”svg”]’).attr(‘src’, function() {
return $(this).attr(‘src’).replace(‘.svg’, ‘.png’);
});
});
})(jQuery);
</script>
<?php
}
add_action(‘wp_footer’, ‘svg_replace’);August 16, 2016 at 12:46 pm #673172And this is what I currently have in my child functions file (below) so just need to know where to add the fallback code and how? Thanks!
<?php
add_theme_support(‘avia_template_builder_custom_css’);
add_theme_support(‘avia_disable_dummy_import’);
function cc_mime_types($mimes) {
$mimes[‘svg’] = ‘image/svg+xml’;
return $mimes;
}
add_filter(‘upload_mimes’, ‘cc_mime_types’);August 16, 2016 at 1:56 pm #673225this thread of mine is a long time ago – and on this time i noticed that this code works well but makes the whole thing extremly slow !:
function svg_replace(){ ?> <script> jQuery(window).load(function(){ jQuery('.avia-msie-8 img[src$="svg"]').attr('src', function() { return jQuery(this).attr('src').replace('.svg', '.png'); }); </script> <?php } add_action('wp_footer', 'svg_replace');
_____________________________________
On that time i thought a bit like you that every browser must handle an installation as well!
But now i think we have to weigh here.
A 100% browser compatibility and very slow ie8 reaction – and 97% browser combatibility to no Ie8 support .IE8 has a market share of 2% of 11% of all IE. Google Maps Api (and the other apis too) did not support IE8 – every IE8 Support has stopped from Microsoft.
So it is much more important that an installation works well on smartphones and tabletts.August 16, 2016 at 2:42 pm #673277Hi!
@purelands hope that reply covers your question.
Always feel free to let us know if any further assistance is needed.Cheers!
BasilisAugust 16, 2016 at 3:57 pm #673319Great thankyou for replying so quickly. So do you recommend I just leave as is without IE8 compatibility? Does SVG work on all other browsers?
August 16, 2016 at 7:22 pm #673376Yes – thats my advice. If all other big Players (Google, Microsoft etc. do not support IE8 – why should we Webdesigners should do so?
you see on that diagramm that 97.23% browsersupport for svg.
And only 0.55% IE8 global use.August 16, 2016 at 7:45 pm #673383Great thanks! I will follow your good advice :)
August 18, 2016 at 5:17 am #674005Hi @purelands,
Great, glad @Guenni007 could help you out :-)
Let us know if you should need any further help on the topic.
Thanks,
Rikard -
AuthorPosts
- You must be logged in to reply to this topic.