{"id":13531366,"url":"https://github.com/filepreviews/wagtail-filepreviews","last_synced_at":"2025-12-30T03:03:33.805Z","repository":{"id":49429138,"uuid":"88413862","full_name":"filepreviews/wagtail-filepreviews","owner":"filepreviews","description":"Extend Wagtail's Documents with image previews and metadata from FilePreviews ","archived":false,"fork":false,"pushed_at":"2021-06-17T20:15:13.000Z","size":28,"stargazers_count":22,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T09:57:56.395Z","etag":null,"topics":["django","filepreviews","python","wagtail"],"latest_commit_sha":null,"homepage":"http://filepreviews.io/blog/2017/04/20/adding-document-previews-to-wagtail/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/filepreviews.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-16T13:08:21.000Z","updated_at":"2024-05-29T08:47:40.000Z","dependencies_parsed_at":"2022-09-08T01:00:21.648Z","dependency_job_id":null,"html_url":"https://github.com/filepreviews/wagtail-filepreviews","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filepreviews%2Fwagtail-filepreviews","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filepreviews%2Fwagtail-filepreviews/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filepreviews%2Fwagtail-filepreviews/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filepreviews%2Fwagtail-filepreviews/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/filepreviews","download_url":"https://codeload.github.com/filepreviews/wagtail-filepreviews/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246700566,"owners_count":20819898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","filepreviews","python","wagtail"],"created_at":"2024-08-01T07:01:02.396Z","updated_at":"2025-12-30T03:03:33.758Z","avatar_url":"https://github.com/filepreviews.png","language":"Python","funding_links":[],"categories":["Apps"],"sub_categories":["Media"],"readme":"wagtail-filepreviews\n====================\n\n.. image:: https://travis-ci.org/filepreviews/wagtail-filepreviews.svg?branch=master\n    :target: https://travis-ci.org/filepreviews/wagtail-filepreviews\n\n.. image:: https://img.shields.io/pypi/v/wagtaildocs_previews.svg\n   :target: https://pypi.python.org/pypi/wagtaildocs_previews\n\nExtend Wagtail's Documents with image previews and metadata from `FilePreviews.io`_\n\nInstalling\n----------\n\nInstall with **pip**:\n\n.. code-block:: sh\n\n    $ pip install wagtaildocs_previews\n\nSettings\n~~~~~~~~\n\nIn your settings file, add ``wagtaildocs_previews`` to ``INSTALLED_APPS``:\n\n.. code:: python\n\n    INSTALLED_APPS = [\n        # ...\n        'wagtaildocs_previews',\n        # ...\n    ]\n\nYou'll also need to set ``WAGTAILDOCS_DOCUMENT_MODEL``.\n\n.. code:: python\n\n    WAGTAILDOCS_DOCUMENT_MODEL = 'wagtaildocs_previews.PreviewableDocument'\n\nURL configuration\n~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    from wagtaildocs_previews import urls as wagtaildocs_urls\n\n    urlpatterns = [\n        # ...\n        url(r'^documents/', include(wagtaildocs_urls)),\n        # ...\n    ]\n\nFilePreviews.io API Keys\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nFor previews to be generated for your documents, you'll need to have a\n`FilePreviews.io`_ account and an application's credentials. Once you have\nthe credentials, add them under the ``FilePreviews`` settings in your\nWagtail admin.\n\nUsage\n-----\n\nSince we're extending via ``WAGTAILDOCS_DOCUMENT_MODEL`` you should be using\n``get_document_model()`` to reference the correct Document model.\n\n.. code:: python\n\n    from wagtail.core.models import Page\n    from wagtail.documents.models import get_document_model\n    from wagtail.documents.edit_handlers import DocumentChooserPanel\n\n\n    class BookPage(Page):\n        book_file = models.ForeignKey(\n            get_document_model(),\n            null=True,\n            blank=True,\n            on_delete=models.SET_NULL,\n            related_name='+'\n        )\n\n        content_panels = Page.content_panels + [\n            DocumentChooserPanel('book_file'),\n        ]\n\n\nIn your template now you'll be able to access the ``preview_data`` field.\n\n.. code:: html\n\n    {% extends \"base.html\" %}\n    {% load wagtailcore_tags %}\n\n    {% block body_class %}resource-page{% endblock %}\n\n    {% block content %}\n        \u003ch1\u003eBook\u003c/h\u003e\n        \u003ch2\u003e{{ page.book_file.title }}\u003c/h2\u003e\n        \u003cimg src=\"{{ page.book_file.preview_data.preview.url|default:'http://placehold.it/300x300' }}\" alt=\"\"\u003e\n    {% endblock %}\n\nConfiguring thumbnail sizes and other options\n---------------------------------------------\n\nBy 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.\n\n.. code:: python\n\n    WAGTAILDOCS_PREVIEWS_OPTIONS_CALLBACK='mysite.utils.get_preview_options'\n\nIn the ``mysite.utils`` module, create a `get_preview_options` method.\n\n.. code:: python\n\n    def get_preview_options(document):\n        return {\n            'sizes': [300],\n            'metadata': ['ocr']\n        }\n\nBonus: Coding video session\n---------------------------\n\nHere’s a coding session video building up to the released package.\n\n.. image:: https://cloud.githubusercontent.com/assets/83319/25309749/3bb64e16-27a3-11e7-8057-350a52484a0a.png\n   :target: https://www.youtube.com/watch?v=p2VY9zX2nNw\n\n.. _FilePreviews.io: http://filepreviews.io/\n.. _FilePreviews options: http://filepreviews.io/docs/endpoints/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilepreviews%2Fwagtail-filepreviews","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilepreviews%2Fwagtail-filepreviews","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilepreviews%2Fwagtail-filepreviews/lists"}