Images
Gives sane defaults to images and figures and provides a way to present beautiful image galleries.
How to use
Pelican
Download the m/images.py file, put it including the
m/
directory into one of your PLUGIN_PATHS
and add m.images
package to your PLUGINS
in pelicanconf.py
. This plugin assumes
presence of m.htmlsanity. The following
shows the minimal configuration together with default values of all available
options. Not specifying the option is equivalent to setting it to a default
value.
PLUGINS += ['m.htmlsanity', 'm.images'] M_IMAGES_REQUIRE_ALT_TEXT = False
To use the image grid feature and image/figure :scale:
option (see
below), in addition you need the Pillow
library installed. Get it via pip
or your distribution package manager:
pip3 install Pillow
Python doc theme
Simply list the plugin in your PLUGINS
. The m.htmlsanity plugin is
available always, no need to mention it explicitly. The same dependencies as
for Pelican apply here. The following shows the minimal configuration
together with default values of all available options. Not specifying the
option is equivalent to setting it to a default value.
PLUGINS += ['m.images'] M_IMAGES_REQUIRE_ALT_TEXT = False
Doxygen theme
The Doxygen theme makes the builtin @image
command behave similarly to
the .. image::
directive of this plugin, if you add a title to it, it
behaves like .. figure::
. It’s possible to add extra CSS classes by
placing @m_class
in a paragraph before the actual image, see the
Doxygen theme-specific commands
for more information. The .. image-grid::
functionality is not available
in the Doxygen theme.
Images, figures
The plugin overrides the builtin image and figure directives and:
- Adds
.m-image
/.m-figure
CSS classes to them so they have the expected m.css image and figure styling. - Removes the
:align:
option, as this is better handled by m.css features and removes the redundant:figwidth:
option (use:width:
instead). - The original
:width:
,:height:
and:scale:
options are supported, only converted to a CSSstyle
attribute instead of using deprecated HTML attributes. The width/height options take CSS units, the scale takes a percentage. - To maintain accessibility easier, makes it possible to enforce
:alt:
text for every image and figure by settingM_IMAGES_REQUIRE_ALT_TEXT
toTrue
.
You can add additional CSS classes to
images or figures via the :class:
or :figclass:
options,
respectively. If you want the image or figure to be clickable, use the
:target:
option. The alt text can be specified using the :alt:
option for both images and figures.
Image grid
Use the .. image-grid::
directive for creating
image grid. Directive contents
are a list of image URLs, blank lines separate grid rows. The plugin
automatically extracts size information and scales the images accordingly. The images are made clickable, the target is the image file itself.
If the image has EXIF information, properties such as aperture, shutter speed
and ISO are extracted and displayed in the caption on hover. It’s also possible
to provide a custom title — everything after the filename will be taken as
a title. If you use ..
as a title (a reST comment), it will disable EXIF
extraction and no title will be shown.
Example of a two-row image grid is below. Sorry for reusing the same two images all over (I’m making it easier for myself); if you want to see a live example with non-repeating images, head over to my blog.
.. image-grid:: {static}/ship.jpg {static}/flowers.jpg {static}/flowers.jpg A custom title {static}/ship.jpg ..