- This topic has 11 replies, 2 voices, and was last updated 2 years, 11 months ago by
David.
-
AuthorPosts
-
March 29, 2023 at 1:43 am #2586729
mkjj
I try to use SVG logos whenever it is possible. For this I have to allow uploading SVGs to the media library. This can easily be done like so:
function cc_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes', 'cc_mime_types');However, since this simple snippet does not provide any validation it is better not to keep it active by default. Is it possible to use a URL in the customizer (or a snippet in the functions.php) instead of the default location? I could then upload the logo to the child theme folder. This would make it much easier to maintain. For me it makes more sense to have the logo combined with the child theme files. (The same is true for icons. I usually don’t upload them to the media library.)
Thank you!
March 29, 2023 at 3:25 am #2586883David
StaffCustomer SupportHi there,
you can use the
generate_logofilter. See here:March 29, 2023 at 4:15 am #2586951mkjj
Sounds great! Thank you! I’ve just tested it, but it seems that I’m missing something. It doesn’t change anything. I switched to my test server and added the filter to a original GP theme with no other plugins (and no caching) installed. Still no luck. I tried several variations.
For a specific page:
add_filter('generate_logo', function ($logo) { if (is_page('who-we-are')) { return 'URL'; } else return $logo; });For the front page:
add_filter('generate_logo', function ($logo) { if (is_front_page()) { return 'URL'; } else return $logo; });For the whole site:
add_filter('generate_logo', function () { return 'URL'; });March 29, 2023 at 5:21 am #2587017David
StaffCustomer SupportAre you displaying the logo in the site header ? Or are you using the Navigation as header?
If you want me to check then share a link to the site 🙂
March 29, 2023 at 5:34 am #2587033mkjj
It’s the default setting. I haven’t even GP Premium activated on this site. Please note that this is just a test server. The site looks quite aweful. 🙂
March 29, 2023 at 5:43 am #2587047David
StaffCustomer SupportAh theres a retina logo stuck in there.
Go to Settings > Site Identity – add a logo to the Retina field, publish changes, then delete that logo and publish the changes. That should get it out the way.March 29, 2023 at 6:02 am #2587075mkjj
Wow, very impressive! 🙂 I would never have thought of that. That’s just fine in this case. However, sometimes I just don’t have a SVG. If I would use this filter for showing different images (like for a category, for example), I couldn’t use an additional retina logo, could I?
March 29, 2023 at 7:05 am #2587172David
StaffCustomer SupportNo you couldn’t use the retina logo, and to be honest i would not bother with retina logos now as most devices screens are x2 or higher DPR.
March 29, 2023 at 11:08 am #2587649mkjj
I absolutely agree when it comes to larger Retina displays like tablets or laptops. On Smartphones, however, a 2x resolution is often over the top. Many images are scaled down anyway. They won’t look better significantly in 2x resolution. File size, on the other hand, can increase dramatically. With logos it’s usually not a big deal, but fullwidth images can easily become huge.
Anyway, this solution is perfectly for me. It applies specifically to SVGs where the resolution does not matter.
March 30, 2023 at 4:16 am #2588566David
StaffCustomer SupportFor reference there is the
generate_logo_outputfilter. With that you can rewrite the logos HTML if you need more control:https://docs.generatepress.com/article/generate_logo_output/
Glad to be of help
March 30, 2023 at 9:29 am #2589148mkjj
Thanks David. It’s really amazing how much we can do with GP in such elegant ways. 🙂
March 31, 2023 at 3:24 am #2590319David
StaffCustomer SupportGlad to be of help!
-
AuthorPosts
- You must be logged in to reply to this topic.