All Projects → filepreviews → wagtail-filepreviews

filepreviews / wagtail-filepreviews

Licence: MIT license
Extend Wagtail's Documents with image previews and metadata from FilePreviews

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to wagtail-filepreviews

Awesome Wagtail
A curated list of awesome packages, articles, and other cool resources from the Wagtail community.
Stars: ✭ 1,527 (+7171.43%)
Mutual labels:  wagtail
django-hyper-editor
Django Integration of Hyper Editor
Stars: ✭ 29 (+38.1%)
Mutual labels:  wagtail
vagrant-wagtail-develop
A script to painlessly set up a Vagrant environment for development of Wagtail
Stars: ✭ 36 (+71.43%)
Mutual labels:  wagtail
Wagtail
A Django content management system focused on flexibility and user experience
Stars: ✭ 11,387 (+54123.81%)
Mutual labels:  wagtail
Wagalytics
A Google Analytics dashboard in your Wagtail admin
Stars: ✭ 176 (+738.1%)
Mutual labels:  wagtail
freeturn
Freelance mission control
Stars: ✭ 50 (+138.1%)
Mutual labels:  wagtail
Reddit Wallpaper Changer
Reddit Wallpaper Changer
Stars: ✭ 96 (+357.14%)
Mutual labels:  wagtail
WF-website
Website for Western Friend, part of the Religious Society of Friends
Stars: ✭ 34 (+61.9%)
Mutual labels:  wagtail
wagtailcommonblocks
Common StreamField blocks for Wagtail
Stars: ✭ 40 (+90.48%)
Mutual labels:  wagtail
wagtailenforcer
The Wagtail arm of the law - enforce security protocols on your Wagtail site
Stars: ✭ 43 (+104.76%)
Mutual labels:  wagtail
Wagtailmedia
A Wagtail module for managing video and audio files within the admin
Stars: ✭ 128 (+509.52%)
Mutual labels:  wagtail
Consumerfinance.gov
Django project protecting American consumers
Stars: ✭ 164 (+680.95%)
Mutual labels:  wagtail
wagtail-headless-preview
Previews for headless Wagtail setups
Stars: ✭ 99 (+371.43%)
Mutual labels:  wagtail
Wagtail Pipit
Pipit is a Wagtail CMS boilerplate which aims to provide an easy and modern developer workflow with a React-rendered frontend.
Stars: ✭ 109 (+419.05%)
Mutual labels:  wagtail
wagtail-redirect-importer
Note: This library is now included in Wagtail 2.10, use the builtin version instead of this.
Stars: ✭ 15 (-28.57%)
Mutual labels:  wagtail
Wagtailtrans
A Wagtail add-on for supporting multilingual sites
Stars: ✭ 103 (+390.48%)
Mutual labels:  wagtail
filepreviews-node
Node.js client library for the FilePreviews.io service.
Stars: ✭ 19 (-9.52%)
Mutual labels:  filepreviews
wagtail-sharing
Easier sharing of Wagtail drafts
Stars: ✭ 46 (+119.05%)
Mutual labels:  wagtail
wagtaildraftail
🐦📝🍸 Draft.js editor for Wagtail, built upon Draftail and draftjs_exporter
Stars: ✭ 23 (+9.52%)
Mutual labels:  wagtail
digihel
City of Helsinki Digital Helsinki Wagtail CMS
Stars: ✭ 19 (-9.52%)
Mutual labels:  wagtail

wagtail-filepreviews

https://travis-ci.org/filepreviews/wagtail-filepreviews.svg?branch=master

Extend Wagtail's Documents with image previews and metadata from FilePreviews.io

Installing

Install with pip:

$ pip install wagtaildocs_previews

Settings

In your settings file, add wagtaildocs_previews to INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    'wagtaildocs_previews',
    # ...
]

You'll also need to set WAGTAILDOCS_DOCUMENT_MODEL.

WAGTAILDOCS_DOCUMENT_MODEL = 'wagtaildocs_previews.PreviewableDocument'

URL configuration

from wagtaildocs_previews import urls as wagtaildocs_urls

urlpatterns = [
    # ...
    url(r'^documents/', include(wagtaildocs_urls)),
    # ...
]

FilePreviews.io API Keys

For previews to be generated for your documents, you'll need to have a FilePreviews.io account and an application's credentials. Once you have the credentials, add them under the FilePreviews settings in your Wagtail admin.

Usage

Since we're extending via WAGTAILDOCS_DOCUMENT_MODEL you should be using get_document_model() to reference the correct Document model.

from wagtail.core.models import Page
from wagtail.documents.models import get_document_model
from wagtail.documents.edit_handlers import DocumentChooserPanel


class BookPage(Page):
    book_file = models.ForeignKey(
        get_document_model(),
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    content_panels = Page.content_panels + [
        DocumentChooserPanel('book_file'),
    ]

In your template now you'll be able to access the preview_data field.

{% extends "base.html" %}
{% load wagtailcore_tags %}

{% block body_class %}resource-page{% endblock %}

{% block content %}
    <h1>Book</h>
    <h2>{{ page.book_file.title }}</h2>
    <img src="{{ page.book_file.preview_data.preview.url|default:'http://placehold.it/300x300' }}" alt="">
{% endblock %}

Configuring thumbnail sizes and other options

By default, image previews and not resized at all. If you want to specify additional FilePreviews options like thumbnail size or metadata, specify the WAGTAILDOCS_PREVIEWS_OPTIONS_CALLBACK option in your settings.

WAGTAILDOCS_PREVIEWS_OPTIONS_CALLBACK='mysite.utils.get_preview_options'

In the mysite.utils module, create a get_preview_options method.

def get_preview_options(document):
    return {
        'sizes': [300],
        'metadata': ['ocr']
    }

Bonus: Coding video session

Here’s a coding session video building up to the released package.

https://cloud.githubusercontent.com/assets/83319/25309749/3bb64e16-27a3-11e7-8057-350a52484a0a.png
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].