Skip to content

Commit

Permalink
Add an ckan.preview.image_formats config option for the image viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfullerton committed Dec 26, 2016
1 parent ccb8dd5 commit e7913c3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ckanext/imageview/plugin.py
Expand Up @@ -17,6 +17,8 @@ class ImageView(p.SingletonPlugin):

def update_config(self, config):
p.toolkit.add_template_directory(config, 'theme/templates')
image_formats = config.get('ckan.preview.image_formats', '').split()
self.formats = image_formats or DEFAULT_IMAGE_FORMATS

def info(self):
return {'name': 'image_view',
Expand All @@ -30,7 +32,7 @@ def info(self):

def can_view(self, data_dict):
return (data_dict['resource'].get('format', '').lower()
in DEFAULT_IMAGE_FORMATS)
in self.formats)

def view_template(self, context, data_dict):
return 'image_view.html'
Expand Down
13 changes: 13 additions & 0 deletions doc/maintaining/configuration.rst
Expand Up @@ -1214,6 +1214,19 @@ Default value: ``text plain text/plain``

Plain text based resource formats that will be rendered by the Text view plugin (``text_view``)

.. _ckan.preview.image_formats:

ckan.preview.image_formats
^^^^^^^^^^^^^^^^^^^^^^^^^^

Example::

ckan.preview.text_formats = png jpeg jpg gif

Default value: ``png jpeg jpg gif``

Image based resource formats that will be rendered by the Image view plugin (``image_view``)

.. end_resource-views
Theming Settings
Expand Down
3 changes: 2 additions & 1 deletion doc/maintaining/data-viewer.rst
Expand Up @@ -200,7 +200,8 @@ View plugin: ``image_view``

If the resource format is a common image format like PNG, JPEG or GIF, it adds
an ``<img>`` tag pointing to the resource URL. You can provide an alternative
URL on the edit view form.
URL on the edit view form. The available formats can be configured using the
:ref:`ckan.preview.image_formats` configuration option.

Web page view
+++++++++++++
Expand Down

0 comments on commit e7913c3

Please sign in to comment.