Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #444833

    i have to use a svg as logo image (because of serif font and thin lines- which should be seen on all screenwidth) – it works nice on all Browsers – except on IE8

    Is there an easy way to get on enfold a fallback to png if Browser does not support svg? Have i to implement modernizr script perhaps?

    #445052

    Hi Guenter!

    I am on a Mac but can you please try adding following code to Functions.php file to check if it helps?

    function add_custom_logo(){
    ?>
    <script>
    jQuery(window).load(function(){
    jQuery('.avia-msie-8 .logo img').attr('src','YOUR IE8 LOGO URL HERE');
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_logo');

    Best regards,
    Yigit

    #445115

    wow this seems to be simple enough.
    I can only test it tomorrow and will than make my news on it. Thanks in advance

    Edit: works well !
    is this a kind of conditional comment
    is it possible to obtain in this manner a generell change from svg to png if same filename is found on IE8 ?

    perhaps like :

      jQuery('img[src$="svg"]').attr('src', function() {  
        return jQuery(this).attr('src').replace('.svg', '.png');
      });
    • This reply was modified 9 years, 6 months ago by Guenni007.
    #445763

    Hi!

    It should work totally fine but please use it as

    
    jQuery('.avia-msie-8 .logo img[src$="svg"]').attr('src', function() {  
        return jQuery(this).attr('src').replace('.svg', '.png');
      });

    Cheers!
    Yigit

    #445767

    it is not possible to handle every svg file in this manner ? only the logo ?

    than this could be used for fallback. If there is a svg file and an existing png with exactly the same name it will be replaced.

    #445771

    Hi!

    In that case, yes. I thought you wanted to only target logo img and not globally :)

    Cheers!
    Yigit

    #445784

    hm ?

    but this doesn’t work:

    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');
    #446263

    this works :

    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');

    so in IE8; if there is a svg file and a png with the same name in the same upload-folder it will be replaced by that png

    • This reply was modified 9 years, 6 months ago by Guenni007.
    #446266

    can be closed now – thanks for your helpful hints

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘svg graphic as logo and fallback png’ is closed to new replies.