How can I change the favicon / icon in plone 6 classic

I have replace the PNG files inside egg but it still using the plone icon.

Any idea?

Many thanks

I finally find out it's cache issue thanks

You can add a favicon through the web via the Site Settings - Website.
There you can upload a custom favicon image.
This might also have some caching
as you can see here it was added in 6.0.0a3: Customise favicon TTW in same way as logo. · Issue #1122 · plone/Products.CMFPlone · GitHub

Does anyone know if you could also adjust the icon via code using the configuration registry (profiles/default/registry.xml).
The setting is called plone.site_favicon
When I look at it in the registry after uploading it looks like this: filenameb64:ZmF2aWN, so I would guess the base64 encoding of the image
I'd like to use a public url in the settings instead of an image.

An url means a subrequest on every page rendering, while icons are heavly cached in the and by the browser. If you mean the icon should have an icon, it has at /favicon.ico.

That makes sence, not having too many request when not needed :slight_smile:
We would like to set a custom favicon on many plone sites that exist, and on every new site we create.
But I guess I will have to look at some theming solution then probably

you can make a script to run from command line. I think you can use also restapi if installed.

https://docs.plone.org/develop/plone/misc/commandline.html

I once did this in registry.xml with Image to Base64 | Base64 Encode | Base64 Converter | Base64 for the image and Text to Base64 | Base64 Encode | Base64 Converter | Base64 for the filename. But beware: if your customer updates the logo afterwards it gets reset by genericsetup once you reimport your profile.

The following would set the current Plone Logo SVG file:

<record name="plone.site_logo">
    <value>filenameb64:cGxvbmVfbG9nby5zdmc=;data64:PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDEzLjAuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMTQ5NDgpICAtLT4KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj4KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJwbG9uZS1sb2dvIiB4bWxucz0iaH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pbGw9IiMwMDgzQkUiIGQ9Ik0xNTQuNTA3LDEzLjQwOWwtMC41NC0xLjA4aC0wLjQ4NnYxLjA4aC0wLjM4OXYtMi41NjRoMC45OTRjMC40ODQsMCwwLjc5NiwwLjMxMywwLjc5NiwwLjc1ICAgIGMwLDAuMzY3LTAuMjI0LDAuNjAyLTAuNTEzLDAuNjhsMC41OTIsMS4xMzZMMTU0LjUwNywxMy40MDlMMTU0LjUwNywxMy40MDl6IE0xNTQuMDU2LDExLjE5NWgtMC41NzV2MC44MDNoMC41NzUgICAgYzAuMjYxLDAsMC40MzctMC4xNDcsMC40MzctMC4zOTlTMTU0LjMxNywxMS4xOTUsMTU0LjA1NiwxMS4xOTV6Ii8+Cgk8L2c+CjwvZz4KPC9zdmc+Cg==</value>
</record>

Is the same problem here?

site_logo and site_favicon can also be added as following (e.g. via zconsole).

import os
import base64

def get_base64_image_from_file(file):
    with open(file, "rb") as image_file:
        datab64 = base64.b64encode(image_file.read())
    basename = os.path.basename(file)
    filenameb64 = base64.b64encode(str.encode(basename))
    base64_image = b"".join( [b"filenameb64:", filenameb64, b";datab64:", datab64] )
    return base64_image

from zope.component import getSiteManager
from plone.registry.interfaces import IRegistry
from plone.base.interfaces.controlpanel import ISiteSchema
import transaction

app._p_jar.sync()

site = app['Plone']
registry = getSiteManager(site).getUtility(IRegistry)
settings = registry.forInterface(ISiteSchema, prefix='plone', check=False)

settings.site_logo = get_base64_image_from_file('/path/to/logo.png')
settings.site_favicon = get_base64_image_from_file('/path/to/favicon.png')

transaction.commit()
1 Like

You can use plone.api (untested) changing the lines between app._p_jar.sync() and transaction.commit() with :

from plone import api
api.portal.set_registry_record('plone.site_logo', get_base64_image_from_file('/path/to/logo.png'))
api.portal.set_registry_record('plone.site_favicon', get_base64_image_from_file('/path/to/favicon.png'))