Site logo

[Resolved] How to configure a specific location for the logo image

Home Forums Support [Resolved] How to configure a specific location for the logo image

Home Forums Support How to configure a specific location for the logo image

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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!

    #2586883
    David
    Staff
    Customer Support

    Hi there,

    you can use the generate_logo filter. See here:

    https://docs.generatepress.com/article/generate_logo/

    #2586951
    mkjj

    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';
     });
    #2587017
    David
    Staff
    Customer Support

    Are 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 🙂

    #2587033
    mkjj

    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. 🙂

    #2587047
    David
    Staff
    Customer Support

    Ah 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.

    #2587075
    mkjj

    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?

    #2587172
    David
    Staff
    Customer Support

    No 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.

    #2587649
    mkjj

    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.

    #2588566
    David
    Staff
    Customer Support

    For reference there is the generate_logo_output filter. 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

    #2589148
    mkjj

    Thanks David. It’s really amazing how much we can do with GP in such elegant ways. 🙂

    #2590319
    David
    Staff
    Customer Support

    Glad to be of help!

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