Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #758766

    Two issues with SVG.

    Logo in header only show when I scale down screen to mobile view. On larger screens nothing shows.
    When I add SVG as an image. Nothing shows. not on mobile, not in larger screens.

    I have tried adding code to functions manually, also tried both safesvg and svg support pluging. All have the same issue, so I¨m thinking its something with the theme.

    #758940

    you have allways to set a width (or heights) rule for svgs – otherwise WP will give them a 1px size!

    f.e.

    .logo img {
    width: 350px;
    height: auto
    }

    the reason why it works on responsive case is that on that moment the logo gets a size rule from enfold theme settings.

    have you got a link to your site?

    #759290

    Hi @snitt,

    Did you try the suggestion posted by @guenni007 and did you have any luck with it?

    Best regards,
    Rikard

    #759975

    Thanks. This works great for logo in header, but what if I want to use svg as an “image” on a page.

    I tried these two ways.
    Adding this code I found to function.

    function fix_svg_thumb_display() {
      echo '
        td.media-icon img[src$=".svg"], img[src$=".svg"].attachment-post-thumbnail { 
          width: 100% !important; 
          height: auto !important; 
        }
      ';
    }
    add_action('admin_head', 'fix_svg_thumb_display');

    I also tried adding this to quick css

    svg {width: 100%; height: auto;}

    I added link to page in first post.

    #760037

    well i think the code snippet above should only do the job for admin area – dashboard media preview.
    btw. there is a spacebar missing between td and . media-icon.
    but i think the code could be a bit changed to:

    function fix_svg_thumb_display() {
    echo '<style type="text/css">
    
        td .media-icon img[src$=".svg"] { 
          width: 100% !important; 
          height: auto !important; 
        }
    
    </style>';
    }
    add_action('admin_head', 'fix_svg_thumb_display');

    showing the svg attachment isn’t the backend site it is in frontend (wp_head influenced)

    function fix_svg_attachment_display() {
    echo '<style type="text/css">
    
        .attachment img[src$=".svg"] { 
          width: 100% !important; 
          height: auto !important; 
        }
    
    </style>';
    }
    add_action('wp_head', 'fix_svg_attachment_display');
    #760041

    As an advanced layout builder element there is a 100% (to the outer container) definition. So no need to say something.
    But if you insert the svg (as img) via standard editor you can change the sizes in text mode of tinymce.

    #760721

    That’s what I though too. But when I place same logo file as used in the header in an avia img box nothing shows on the page.
    This is not critical. Most important is to have logo in header work as desired.

    Do you know how I can left align logo when the header is minimized/scrolled?
    I think I need to set a smaller size on logo once header is minimized to make this happen, but I don’t know what code I should use to change this.

    Thanks for helping out.

    #760937

    on svg you can open the svg file in a good text editor (sublime text on Mac OSX or notepad++ on PC)

    on top of your svg there is some code like this:

    <svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
    	 viewBox="110 33 400 120" enable-background="new 110 33 400 120"  xml:space="preserve">

    you can manually enter : preserveAspectRatio=”xMinYMin meet” (just before xml:space so there is:

    <svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
    	 viewBox="110 33 400 120" enable-background="new 110 33 400 120" preserveAspectRatio="xMinYMin meet" xml:space="preserve">

    this code offers you the influence how the svg shrinks. xMinYMin means it goes to the top left corner
    if you like to center the logo in x-direction : xMidYMin means it centers on shrinking in x-direction but it goes to top etc
    xMaxYMax – goes to right bottom corner of the surrounding container.

    #760961

    by the way placing the svg to the image box – give the image box a custom class and f.e. svgimg

    than place in your quick css:

    .svgimg .avia_image {
        height: auto;
        width: 350px;
    }

    or 100%

    #950881

    Hey guys, I’m having the same problem (SVG logo doesn’t appear on large screens) and I dont understand code that well.
    Could you tell me where to place the code snippet to make this work?

    Thanks

    #951567

    Hi dror2us2,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?

    Best regards,
    Victoria

    #952106

    Thank you Victoria, right after my post I tried setting a rule for width and height for the SVG logo, and it worked.
    Thanks for the fast reply.

    #952466

    Hi,

    Great, thanks for the feedback. Please let us know if you should need any further help on the topic.

    Best regards,
    Rikard

    #952649

    Thank you, that’s all for now. Thanks again for the quick reply.

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