Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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’);

    #673172

    And 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’);

    #673225

    this 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.

    #673277

    Hi!


    @purelands
    hope that reply covers your question.
    Always feel free to let us know if any further assistance is needed.

    Cheers!
    Basilis

    #673319

    Great thankyou for replying so quickly. So do you recommend I just leave as is without IE8 compatibility? Does SVG work on all other browsers?

    #673376

    Yes – thats my advice. If all other big Players (Google, Microsoft etc. do not support IE8 – why should we Webdesigners should do so?

    http://caniuse.com/#feat=svg

    you see on that diagramm that 97.23% browsersupport for svg.
    And only 0.55% IE8 global use.

    #673383

    Great thanks! I will follow your good advice :)

    #674005

    Hi @purelands,

    Great, glad @Guenni007 could help you out :-)

    Let us know if you should need any further help on the topic.

    Thanks,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.