wagtail-filepreviews
Extend Wagtail’s Documents with image previews and metadata from FilePreviews
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)),
# ...
]
Usage
Since we’re extending via WAGTAILDOCS_DOCUMENT_MODEL you should be using get_document_model() to reference to correct Document model.
from wagtail.wagtailcore.models import Page
from wagtail.wagtaildocs.models import get_document_model
from wagtail.wagtaildocs.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 %}
Metadata
Release files for wagtaildocs-previews 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wagtaildocs_previews-0.0.1.tar.gz | 9.4 kB | Without provenance | Details for wagtaildocs_previews-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wagtaildocs_previews-0.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for wagtaildocs_previews-0.0.1-py2.py3-none-any.whl |
Total release size: 22.1 kB
Release files / wagtaildocs_previews-0.0.1.tar.gz
| Download URL | wagtaildocs_previews-0.0.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2f0e24ef256f408d1b010168221c349a354b418425afa1b4be6219e8408fcf2
|
|
BLAKE2b-256 checksum How to use checksums |
46ebd9132966bc8c42233a60979d77ec54559b6c87c86fc8074478ecd5b6b96d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / wagtaildocs_previews-0.0.1-py2.py3-none-any.whl
| Download URL | wagtaildocs_previews-0.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
4c3e32f960a4523f7c1e54f0421dd36639d6172f0094354803263523b2fe9288
|
|
BLAKE2b-256 checksum How to use checksums |
7aa6c57a5d56eb900437941439ff55af8df7ec5da63c15544c6709a7491489b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for wagtaildocs-previews 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.