Table of Contents
Plone extension providing smart logo handling. Based on an svg Logo or Icon the extension is able to produce all kinds of scales such as apple touch icons or android PWA logos.
Plone 4.3.x Plone 5.1.x
Two important points for developers.
If you experience problems converting some svg's to png's, like getting a all transparent PNG. Install imagemagick with librsvg. Also don't install imagemagick version 7. Not gonna work.
brew install imagemagick@6 brew link imagemagick@6 --force
Also make sure /usr/local/opt/imagemagick@6/bin is in the PATH
- Add the package to your buildout configuration:
[instance] eggs += ... ftw.logo
- Fork this repo
- Clone your fork
ln -s development.cfg buildout.cfg
bin/test to test your changes.
Or start an instance by running
Basically there are just logo and icon scales.
The logo scales are mostly used on the top left and can have
any dimensions. The converter creates a
mobile_logo from the
base logo which has to be an svg file.
The icon scales are used for
android PWA icons.
The base icon must be square, and the scaled icons will also if course be square.
In summary we need two different SVG source files. One with an arbitary ratio
and the other with a square ratio.
All scales are taken from https://realfavicongenerator.net/.
The available scales are:
- get_logo (virtual)
The get_logo virtual scale returns either the BASE (svg from ZCML) or if available the overridden BASE or LOGO scale from the Dexterity content type.
The converter holds all the scale definitions and so is able to generate
the scales needed. wand.py is used
to convert the svg source files into the different scales.
The converter generates a modified
image proxy which is able to return the actual blob of the scale behind the proxy.
Refer to the write images and
resizing and cropping
section for more information about how the converter uses
The extension introduces a custom icon and logo directive for zcml.
Both directives accept
The base attribute defines the svg source files for all scales.
The multiadapter adapts context and request. So the svg source file
can be overridden by using one or both of
First include the directive:
<configure ... xmlns:logo="https://namespaces.4teamwork.ch/ftw.logo" ... >
<logo:logo base="logo.svg" />
The next block will override the previous config.
<logo:logo base="custom_logo.svg" layer="your.product.interfaces.IYourProductLayer" />
It's also possible to define a pre scaled image for logo, mobile and favicon.
<logo:logo base="resources/min.svg" logo="tests/fixtures/logo.png" mobile="mobile.png" primary_logo_scale="logo" /> <logo:icon base="icon.svg" favicon="favicon.ico" />
Please remember a base svg is required anyway. If you can't supply one, simply put in a transparent empty svg. If you dont't have one you can use the one from this package, which is located in the resources folder. It's called min.svg. Also set the primary_logo_scale to "logo", since ftw.logo always prefers the svg over all other scales.
Change default height for logo and mobile scale by zcml:
<logo:logo base="resources/min.svg" height="200" mobile_height="30" />
All logos and icons can be accessed through the logo browser view.
The URL consists of the browser view name
@@logo followed by the type of the
image and the actual scale.
@@logo/logo/BASEwill show the svg logo source.
@@logo/icon/APPLE_TOUCH_ICONwill show the apple touch icon as a png image.
Caching is provided by adding a query string parameter to every logo request. The cachekey consist of a sha256 hash including the files binary data. If you have plone.app.caching enabled, install the caching profile from ftw.logo. This will define etag values so the viewlet is cached properly.
- Github: https://github.com/4teamwork/ftw.logo
- Issues: https://github.com/4teamwork/ftw.logo/issues
- Pypi: http://pypi.python.org/pypi/ftw.logo
This package is copyright by 4teamwork.
ftw.logo is licensed under GNU General Public License, version 2.