Code Monkey home page Code Monkey logo

wagtail-simple-gallery's Introduction

Wagtail Simple Gallery

Is an extension for Torchbox's Wagtail CMS for creating a simple image gallery either by creating a page using the template or a templatetag.

Current version works with Wagtail 2.8.x - 6.1.x & Django 2.2.x - 5.0.x.

Getting started

Install

  • Install via pip pip install wagtail-simple-gallery.
  • Add wagtail_simple_gallery to INSTALLED_APPS in your project settings.
  • Run python manage.py migrate wagtail_simple_gallery.

Use

  • Create a new collection in Wagtail CMS: Settings -> Collections.
  • Add or upload images to the collection.
  • Create a new page using the Gallery index type and select the new collection.
  • You are done, preview or publish the page and you should see the gallery in action.

Features / Options

  • Toggleable Lightbox for viewing images.
  • Show images from selected collection.
  • The amount of images shown on one page (before the paginator kicks in) is changeable.
  • A crude way to order the images shown on a gallery page. By default newest images are shown first, but this can be changed in the page content settings. If it's set to "Image title" then you can manually order images by inserting [<number>] into their title: "[00004] Cute cat".
  • Tags.

Settings

SIMPLE_GALLERY_TEMPLATE

You can override the SimpleGalleryIndex page template with this setting. Default: wagtail_simple_gallery/simple_gallery_index.html

SIMPLE_GALLERY_ADMIN_URL_ROOT

You can use this with the Admin Interface if you use something other than "admin" for accessing the cms admin panel. Default: admin

SIMPLE_GALLERY_PAGE_TYPE

The page type presented to a Wagtail CMS user can be adjusted with this setting. Default: Gallery index.

Templatetags

{% load wagtailsimplegallery_tags %}

{% simple_gallery %} inclusion tag

Uses the template wagtail_simple_gallery/simple_gallery.html. You can use the simple-gallery style with this tag using: <link rel="stylesheet" href="{% static 'css/simple-gallery.css' %}">.

  • collection (default: None): Show images from this collection. Required, example: {% simple_gallery collection="Root" %}.
  • tags (default: None): Filter images by their tags. Example: {% simple_gallery tags="cats dogs" %}.
  • image_limit (default: None): Limit the amount of images to show. Example: {% simple_gallery image_limit=4 %}.
  • use_lightbox (default: True): Use lightbox for viewing images. Example: {% simple_gallery use_lightbox=False %}.

{% img|original_url %} filter

  • Takes wagtails Image object and returns its real original url instead of the one that wagtail creates. Example: /media/original_images/foo.jpg.

{% img.alt|hide_num_order %} filter

  • Hides the first occurance of [<number>] in the image title. E.g "[0010] Cute cat" -> "Cute cat"

Template

Look at simple_gallery_index.html template for an example or copy paste it and start modifying to make it look a part of your page. Your custom simple_gallery_index.html template should reside in /templates/wagtail_simple_gallery/simple_gallery_index.html

Or if simple_gallery_index.html is good enough for your use, then you can just create a simple_gallery_base.html in your own templates directory with the following content:

{% extends "base.html" %}

{% block content %}{% endblock %}

Admin Interface

It is suggested to take advantage of the existing Wagtail setting:

WAGTAILIMAGES_INDEX_PAGE_SIZE = 32

wagtail-simple-gallery's People

Contributors

db654 avatar dnsl48 avatar frague59 avatar hongquan avatar joj0 avatar morezmartin avatar temeez avatar thht avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wagtail-simple-gallery's Issues

Error with custom image model

Hi
In the models.py file, in the get_gallery_images function should say
images = get_image_model().objects.filter(collection__name=collection)
instead images = Image.objects.filter(collection__name=collection)
Thank you!
Kind regards
Victor

Ordering of images in a gallery

Is there a way to order the gallery ? As I see, ordering is based on creation date, but wagtail provides an "Orderable" model mixin, that allows the ordering.

Do you think this kind of feature could be implemented ?

Support for wagtail 1.8/1.9

Hi,

I'm currently working on a 1.9 wagtail site, have you projected to support it ?
I can look at the code and may be do the job and propose a pull request...

Thanks !

Wagtail 6.x not supported due to requirements.txt

The usual upgrade cycle, sorry. I'm trying to install this package, but I'm using Wagtail v6.1.1. The error on a build (I'm using Docker) is:

22.00 ERROR: Cannot install -r /requirements.txt (line 15) and wagtail<6.9 and >=6.0 because these package versions have conflicting dependencies.
22.00
22.00 The conflict is caused by:
22.00 The user requested wagtail<6.9 and >=6.0
22.00 wagtail-simple-gallery 0.10.0 depends on wagtail<6.0 and >=2.5
22.00
22.00 To fix this you could try to:
22.00 1. loosen the range of package versions you've specified
22.00 2. remove package versions to allow pip attempt to solve the dependency conflict

I know there are some changes in Wagtail that might not simply allow an increase in the Wagtail version in requirements.txt, but maybe it would be that simple?

I'm a bit new with this stuff, but would be willing to have a go at testing Wagtail 6.x compatibility and creating a fix. First time trying something like this, so please bear with me (newbie).

Extra comment:

I wonder if it might be a reasonably easy fix. I see you've got tests for the imports of some Wagtail features in models.py, e.g.:

try:
from wagtail.admin.edit_handlers import FieldPanel
except ImportError:
from wagtail.admin.panels import FieldPanel

So maybe that's already enough to support Wagtail 6.x? I know there were some changes to where these classes like FieldPanel were moved, going from Wagtail 4 - 5.

Show whole collection in lightbox

Hi, it's not really an issue but rather asking for some advice for an enhancement of wagtail-simple-gallery.

In a picture collection on the web usually a user would expect when clicking on an image they then can swipe (on mobile) or click (on desktop) through the whole collection of available pictures. In case of wagtail-simple-gallery + lightbox, only the currently page of pictures will be available to swipe/click through. I am brainstorming about possibilities to load all pictures into lightbox to make that possible. I'm looking at this right now: https://github.com/feimosi/baguetteBox.js#showindex-gallery

A pragmatical approach would be to load all pictures from the collection, additionally to the paginated ones, into a hidden div (is that even possible?? my css knowledge is so bad ;-)) and then use .run and .show as described in the docs link above.

Do you have any better ideas? Wanna help me brainstorm?

Using deprecated Django tags in templates

This template starts off using depreciated templates and doesn't invoke any optional class parameter to try to use it. Remove usage of ifnotequal

https://code.djangoproject.com/ticket/31532

Should modify basic template away from use of standard IF instead for the comparison in the

/templates/wagtail_simple_gallery/simple_gallery_index.html

Invalid block tag on line 38: 'ifnotequal', expected 'empty' or 'endfor'.

Use with Jinja2 template?

Is it possible to override template path for this app? I want to use my Jinja2 template (with extension *.jinja).

Wagtail 5.x support

Hi,

I'm starting a new wagtail project, with wagtail 5.1.

I'll provide a PR with compatibility with this release of Wagtail.

Thanks !

django 3 compatibility

hi,
is there a possibility to make this great project compatible to django 3? would you have time for it?
if not, i might be able to give it a shot....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.