elegant icon indicating copy to clipboard operation
elegant copied to clipboard

Photo Plugin seems to support inline galleries now

Open Ockenfuss opened this issue 1 year ago • 0 comments

In the elegant documentation, it says photo galleries can only be added at the end of the article and that there is need for further development (link).

It seems like in the meanwhile, the photos plugin supports inline galleries. According to the documentation, there must be a file "inline_gallery.html" available, which provides a template for a gallery. Subsequently, the user can just write gallery::{photo}example_gallery to create an inline gallery (see the examples of the photos plugin)

When I had a first try, it seemed quite easy to implement this in elegant: Just move the following lines of code from article.html to its own template file inline_gallery.html. Be aware that there are some small modifications.

Article.html, to be deleted:

            {% if article.photo_gallery %}
            <div class="gallery">
                {% for title, gallery in article.photo_gallery %}
                <h1>{{ title }}</h1>
                {% for name, photo, thumb, exif, caption in gallery %}
                <a href="{{ SITEURL }}/{{ photo }}" title="{{ name }}" exif="{{ exif }}" caption="{{ caption }}"><img
                        src="{{ SITEURL }}/{{ thumb }}"></a>
                {% endfor %}
                {% endfor %}
            </div>
            {% endif %}

New file Inline_gallery.html:

<div class="gallery">
    {% for title, gallery in galleries %}
        <h1>{{ title }}</h1>
        {% for name, photo, thumb, exif, caption in gallery %}
            <a href="{{ SITEURL }}/{{ photo }}" title="{{ name }}" exif="{{ exif }}" caption="{{ caption }}"><img src="{{ SITEURL }}/{{ thumb }}"></a>
        {% endfor %}
    {% endfor %}
</div>

Additionally, you might need the following in you pelicanconf.py:

PHOTO_LIBRARY="path/to/galleries"
PHOTO_INLINE_GALLERY_ENABLED=True
PLUGINS= ['photos']

Would it make sense to adapt the elegant theme in a similar way? What do you think?

Ockenfuss avatar May 02 '23 15:05 Ockenfuss