getpelican/pelican-plugins — pull request #32 by dflock (2013-05-30 11:22:28+00:00)
Title: Better Figures & Images Plugin

I added a new plugin that improves `` and `

` elements. It adds `style="width: ???px; height: auto;"` to both, based of the actual dimensions of the image file.

This plugin:

- Adds a `style="width: ???px; height: auto;"` attribute to any `` tags in the content, by checking
the dimensions of the image file and adding the appropriate `style="width: ???px; height: auto;"` to the `` tag.
- Also finds any `div class="figures"` tags in the content, that contain images and adds the same style to them too.
- If RESPONSIVE_IMAGES setting is true, it adds `style="width: ???px; max-width: 100%; height: auto;"` instead.
- Corrects Alt text: If an img alt attribute = the image filename, it sets it to ""

There's a complete explanation with examples here: http://duncanlock.net/blog/2013/05/29/better-figures-images-plugin-for-pelican/

It's tested and seems to work well and allows much better CSS styling of figures in particular. There is test input and example output in the /test_data folder, but alas no automated/unit test yet.

I'm fairly new to Pelican and this is also my first pelican plugin, so I'm sure it could be better - indeed there may be a much better way to achieve this in Pelican in a different way, but this seemed like the most obvious way at the time.

If you want changes before merging, or know of a much better way, please let me know!

Thanks,
Dunc