Hi,
I want to change the logo when browser window is between 767px and 990px.
I have tried with the suggestions from this post
but it doesn’t seem to work. Maybe because it is .svg logo.
Can you provide a code for changing the svg logo on screens between 767 and 990?
Thanks.
Hey Jakob Roer,
Thank you for the inquiry.
Are you planning to use another svg on mobile view? This might not work with the current script because you can’t dynamically replace the svg file with another. Please try to replace the code with the following snippet and make sure to use an image with a PNG or JPG format.
add_action('wp_footer', 'ava_custom_script');
function ava_custom_script(){
?>
<script type="text/javascript">
(function($)) {
$(document).ready( function() {
if($(window).innerWidth() <= 1024){
$('<img src="IMAGE_URL_HERE" />').appendTo("div .logo");
}
});
})(jQuery);
</script>
<?php
}
Make sure to replace the placeholder IMAGE_URL_HERE with the actual image URL.
Best regards,
Ismael
Hi Ismael,
Thanks for your reply. I’ve tried your code but it doesn’t seem to be doing what was intended.
I have made the header transparent on mobile devices. The problem is that it is showing the regular logo and not the logo set for transparent mode.
I fixed this using this code to change the logo on mobile devices and it works, but there is still a gap between 768-990px screens.
… or in another sentence, it doesn’t work for browser windows smaller than 990px.
Hi again,
I figured it out. I changed the fill color on the .svg for smaller screens.
You can close this thread :)
Thanks.