
Tagged: header, logo, svg, transparency
-
AuthorPosts
-
June 26, 2025 at 6:35 pm #1485962
Dear @Ismael,
you helped me out with a piece of code (see post #1484511) and it is working as expected:
function avf_no_inline_svg_mod($attachment_id, $url) { $logo_url = avia_get_option( 'logo' ); $logo_url_transparency = avia_get_option( 'header_replacement_logo' ); if ($url && $url == $logo_url || $url && $url == $logo_url_transparency) { return true; } return false; } add_filter('avf_no_inline_svg', 'avf_no_inline_svg_mod', 10, 2);
With this snippet added to functions.php the logo of my page is not rendered as path but instead loaded as an SVG image. Works for normal logos and the ones set in the transparency settings.
However, on pages with transparent header but smaller screen the normal logo is loaded. Not the transparent one. Any idea why? (Maybe helpful: I keep the transparent header for mobile menu due to a change in avia-sticky-header.js – code from the forum)
I appreciate your help.
Kind regards,
DanielJune 27, 2025 at 7:07 am #1485989Hey Daniel,
Thank you for the inquiry.
The same SVG logo image is displayed on small screens when we checked the previous site. Would you mind providing a screenshot?
Best regards,
IsmaelJune 27, 2025 at 7:24 am #1485991Hi Ismael,
on an other page I have the header on mobile sticky and transparent too (avia-sticky-header.js). See link.
June 27, 2025 at 8:37 am #1486004Hi,
Did you remove the filter? The markup is the same when we checked. Please check the screenshot in the private field.
Best regards,
IsmaelJune 27, 2025 at 9:12 am #1486010No, I did not remove it. Just go below 990px width. Than the alternate logo part is hidden by
display: none
.The longer I think about it I think the problem isn’t the filter. It is because of the changes in avia-sticky-header.js and that those aren’t reflecting the two different logo types …
June 29, 2025 at 4:15 pm #1486108Hi,
When I check on mobile after scroll the round logo is transparent but it has a background-color, try this css to remove it:@media only screen and (max-width: 990px) { #header.header-scrolled .logo a { background-color: transparent; } }
Best regards,
MikeJune 30, 2025 at 10:05 am #1486142Hi Mike,
it is about the logo that changes in header before scroll. After scroll everything is fine. Before scroll there is a white logo (the one defined for transpareny mode) shown on large screen sizes (white). On smaller screens the transparency mode logo is overruled by the normal one (blue).
I think I can sort it out with css but am curious if there is an error in the filter (see above) or is it because of the altered avia-sticky-header.js.
All the best,
DanielJune 30, 2025 at 9:50 pm #1486170Hi,
When I check, on mobile, before scroll, the logo is transparent. It is only after scroll do I see an issue with the small round one.Best regards,
MikeJuly 1, 2025 at 11:16 am #1486191Hi Mike, as I said: It is not about the small round one. Everything finde with that. And it is not about a transparent background either. The logo in the header is different for the mobile versions and the desktop version. For the desktop version (above 990px) the logo is white (as defined in the theme’s transparency settings) and for the mobile/smaller versions it is blue – that is the normal logo, not the one defined in the theme’s transparency settings. Now my question is: Why? Is anything of the transparency logic defined in avia-sticky-header.js? Than this could be the reason, because I altered the avia-sticky-header.js
July 1, 2025 at 11:29 am #1486192can you post the link to that page? I would like to have a look to that svg.
And what have you changed inside sticky header script?
____________________btw: see here a testpage: https://webers-testseite.de/
because it is an inline svg i do not use the transparency logo – i change the fill colors by css – if header is transparent or not..html_header_transparency #header:not(.header-scrolled) .buchstabe { fill: #FFF; }
July 1, 2025 at 1:38 pm #1486196Hi :-) The svg is loaded as image!
function avf_no_inline_svg_mod($attachment_id, $url) { $logo_url = avia_get_option( 'logo' ); $logo_url_transparency = avia_get_option( 'header_replacement_logo' ); if ($url && $url == $logo_url || $url && $url == $logo_url_transparency) { return true; } return false; } add_filter('avf_no_inline_svg', 'avf_no_inline_svg_mod', 10, 2);
That works as expected on larger screens. But not on mobile. If the header is fixed and shrinking on mobile too. That’s why I changed the avia-sticky-header.js with a code from you, found in the forum.
July 1, 2025 at 2:04 pm #1486198My interest in seeing the SVG was because you might not need an alternative logo. Why is there a construct with alternative logos in Enfold for transparent headers? In most cases, the only issue is the logo’s contrast with the background. However, since it is very difficult to influence a PNG or JPG in this respect, a second logo was used. As above, white text on a dark background.
With an inline SVG, however, I can achieve this by changing the elements within the SVG using external CSS.if you only need these classes in the mobile case (header-scrolled or header-scrolled-full) to have a different logo, you can also change your logo via the class (av_header_transparency).
July 1, 2025 at 2:29 pm #1486204That is correct. But sometimes SVGs are quite complex in structure and for those cases I use the code above to load them as a file rather than the path. I can sort it out with CSS, no problem. But I dont’t understand the behaviour right now. Is anything in avia-sticky-header.js relevant for loading the logo from the theme’s transparency settings on mobile?
July 1, 2025 at 2:31 pm #1486205you only changed that line?
if( shrinking && ! isMobile )
July 1, 2025 at 2:33 pm #1486206In avia-sticky-header.js?
July 2, 2025 at 8:36 am #1486226Apart from that, why don’t you want an inline SVG for the logo?
You just have to make sure that the classes with same selector used within the SVG have the same declarations, and that different CSS declarations have different classnames.
To be on the safe side, I would use completely different class names.
This is important because the alternate logo is listed in the DOM after the standard logo. Therefore, a selector inside the alternate logo would always prevail. (e.g. if in both logos there are classes like st1 or cls1 ( as used by illustrator) the fill color for cls1 of the alternate-logo will win the race )July 2, 2025 at 4:41 pm #1486246I basically agree with you. But that means having the appropriate files, editing them if necessary and in addition writing CSS rules for the display in the transparent header. That’s a lot of work (if you’re responsible for a lot of homepages) and that is why I like to continue working with SVGs as linked files. This also makes exchange of a logo easier. In my opinion.
Unfortunately my question has still not been answered: Is it defined somewhere in avia-sticky-header.js which logo file is loaded for the transparent header? Is there a difference with regard to mobile screens? If so, I would have to take another look at the file and make the necessary adjustments.
July 3, 2025 at 8:16 am #1486266by the way: that snippet from your first post – does not work on my testinstallation ( Enfold 7.1.1). I do allways have inline svg.
As far as i know the avia-snippet-sticky-header does only rule the shrink amount , header height. (Two classes are toggled on scrolling)
On mobile devices the shrinking is set to off by that line i mentioned.July 3, 2025 at 8:47 am #1486267I built that code with Ismael in an other thread. Works on multiple installations for me. All with Enfold 7.1.1. In the theme settings I put the logos as SVG files and those files are loaded in the frontend. As it used to be in older Enfold versions.
Now I double checked the avia-snippet-sticky-header.js and see it just as you described: only styling of the header, no tweaking of the logo
On an other installation I tried the code and it is working as expected, but same behaviour on mobile: the normal logo is loaded, not the one defined in the transparency settings.
I believe it is because usually the header isn’t transparent on mobile. Even with header set to transparent in backend it is only transparent for the larger screen sizes. On mobile the header is normal and therefore the normal logo is loaded and used instead of the one from the transparency settings.
My conclusion is that I will have to sort it out with CSS since both logos are available in the code.
But what’s interesting: If I use the SVGs as path (without the code mentioned above) the version from the transparency settings is used on mobile too. That’s different to older Enfold versions and to the behaviour with a logo as image file. Or am I wrong?
July 3, 2025 at 1:45 pm #1486277ok – sorry i only tested the code on my webers-testseite.de
this is a playground for all things i try to show for other participants. ( That has a child-theme functions.php with over 4800 lines ) maybe there is something that disturbs that snippet.here on a nearly untouched installation it works on mobile too! ( at least in DevTools for mobile emulation )
July 3, 2025 at 2:17 pm #1486279Thank you for giving it a try. Very interesting. In my installations there is the following CSS:
@media only screen and (max-width: 989px) { .responsive.html_mobile_menu_tablet #top .av_header_transparency.av_alternate_logo_active .logo a > img, .responsive.html_mobile_menu_tablet #top .av_header_transparency.av_alternate_logo_active .logo a > svg { opacity: 1; } } @media only screen and (max-width: 989px) { .responsive.html_mobile_menu_tablet #top .av_header_transparency .logo img.alternate, .responsive.html_mobile_menu_tablet #top .av_header_transparency .logo .subtext.avia-svg-logo-sub { display: none; } }
Don’t know where it comes from. The first shows the normal logo, the second hides the alternate version below 990px. That’s exactly the error.
In your installation it is like that:
#top .av_header_transparency.av_alternate_logo_active .logo a > img, #top .av_header_transparency.av_alternate_logo_active .logo a > svg { opacity: 0; } .av_header_transparency .logo img.alternate, .av_header_transparency .logo .subtext.avia-svg-logo-sub svg { opacity: 1; }
No query whatsoever. But the CSS above is not from me. It has to be from Enfold.
Your test is: Logo in backend, alternate logo in backend, code from above in functions, page set to “transparent header” – correct?
July 3, 2025 at 5:40 pm #1486284but that comes from layout.css – no custom css at all:
#top .logo img.alternate { opacity: 0; } #top .av_header_transparency .logo a > img { opacity: 0; } #top .av_header_transparency .logo img.alternate { opacity: 1; }
July 4, 2025 at 5:09 am #1486298Hi,
Before scroll there is a white logo (the one defined for transpareny mode) shown on large screen sizes (white). On smaller screens the transparency mode logo is overruled by the normal one (blue).
Did you apply the css correction? This is what we see when we check the site on screen sizes below 990px.
(Screenshot redacted)
Best regards,
IsmaelJuly 4, 2025 at 10:26 am #1486305Hi! In my testing I deactivated the code and as I already mentioned the path versions are loaded correctly if the code is inactive. White an all screen sizes.
With the active code in functions.php there is only the white one on large screens (the one defined for transpareny mode) and the blue one (normal logo) on screen sizes below 990px. Activated the code and you can see the behaviour online.
Maybe you can check CSS because what’s interesting: I don’t have the lines mentioned from Guenni007 in my layout.css. See our posts above.
Thanks in advance!
Kind regards,
DanielJuly 4, 2025 at 10:37 am #1486306try:
@media only screen and (max-width:989px) { .responsive.html_mobile_menu_tablet #top .av_header_transparency .logo img.alternate, .responsive.html_mobile_menu_tablet #top .av_header_transparency .logo .subtext.avia-svg-logo-sub { display:block !important } .responsive.html_mobile_menu_tablet #top .av_header_transparency.av_alternate_logo_active .logo a > img, .responsive.html_mobile_menu_tablet #top .av_header_transparency.av_alternate_logo_active .logo a > svg { opacity:0 } }
_______________
in layout.css there is that rule – this has to be overwritten – if you set your header to fixed position:
@media only screen and (max-width: 989px) { .responsive.html_mobile_menu_tablet #top .av_header_transparency .logo .subtext.avia-svg-logo-sub, .responsive.html_mobile_menu_tablet #top .av_header_transparency .logo img.alternate { display: none; } } @media only screen and (max-width: 767px) { .responsive #top .av_header_transparency .logo .subtext.avia-svg-logo-sub, .responsive #top .av_header_transparency .logo img.alternate { display: none; } }
July 4, 2025 at 10:46 am #1486307this is the whole css for transparency fixed header on small screens ( if header_meta is present some height values had to be corrected ) from my testpage above:
@media only screen and (max-width:989px) { .responsive #top #wrap_all #header .container { width:95%; max-width:95% } #header { position:fixed !important; height:80px !important; max-height:80px !important } .responsive #top .av-logo-container , .responsive #top .logo a, .responsive #top .logo img, .responsive #top .logo svg { height:80px !important; max-height:80px !important; line-height:80px !important } .responsive #top .av-main-nav .menu-item-avia-special a { height:80px !important; line-height:80px !important } #top .header_bg, .responsive.html_mobile_menu_tablet #top #wrap_all .av_header_transparency { background-color:transparent !important } .responsive.html_mobile_menu_tablet #top #wrap_all #header:not(.av_header_transparency) { background-color:#FFF !important } #top #header.header-scrolled .header_bg { background-color:#FFF !important } .responsive.html_mobile_menu_tablet #top .av_header_transparency .logo img.alternate, .responsive.html_mobile_menu_tablet #top .av_header_transparency .logo .subtext.avia-svg-logo-sub { display:block !important } .responsive.html_mobile_menu_tablet #top .av_header_transparency.av_alternate_logo_active .logo a > img, .responsive.html_mobile_menu_tablet #top .av_header_transparency.av_alternate_logo_active .logo a > svg { opacity:0 } html:not(.html_header_transparency) #top .header_bg { background-color:#FFF !important } .responsive:not(.html_header_transparency).html_mobile_menu_tablet.html_header_top #top #main { padding-top:80px !important } }
July 7, 2025 at 10:43 am #1486391Yes. That’s very interesting. Never stumbled over this part of layout.css even with some fixed and transparent headers for mobile on various homepages. Therefore the code in functions.php is correct and the logo is loaded as SVG file but by CSS the normal version is shown on smaller screens. Sorted the CSS and now everything is as expected.
Thanks to all helping hands for bringing light into the darkness!
July 7, 2025 at 9:46 pm #1486418Hi,
I removed the screenshot as requested, glad Guenni007 could help, thank you Guenni007, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Logo as SVG’ is closed to new replies.