Extension Dataset Thumbnail


Extension Basics

Title
Dataset Thumbnail
Name
ckanext-datasetthumbnail
Type
Public extension
Description
CKAN extension that adds support for generation and display of thumbnail images for datasets from JPEG or PNG resources.
CKAN versions
Download-Url (zip)
Last commit
7 years ago (2019-02-25 11:57:27)
Url to repo
Category
Content Management


Background Infos

Description (long)
Show details

ckanext-datasetthumbnail

This CKAN extension adds support for generation and display of thumbnail images for datasets.

The helper function thumbnail_url can be called from a template, as in this example:

{% block thumbnail %}
{% set thumbnail = h.thumbnail_url(package.id) %}
{% if thumbnail %}
    <a href="{{ h.url_for(controller='package', action='read', id=package.name) }}">
    <img class="dataset-list-thumbnail" src="{{ thumbnail }}">
    </a>
{% endif %}
{% endblock %}

Thumbnail Selection Logic

  • If a resource exists with the name thumbnail.png, this will be used.
  • If no resource exists with this name and the logged-in user has sufficient access, the thumbnail will be generated from the first matching JPEG or PNG resource.
  • If no thumbnail exists at this point, a placeholder image will be used.

Requirements

  • CKAN 2.5.2
  • Pillow 3.2.0 (with PngImagePlugin and JpegImagePlugin)

Installation

To install ckanext-datasetthumbnail:

  1. Activate your CKAN virtual environment:
. /usr/lib/ckan/default/bin/activate
  1. Install the ckanext-datasetthumbnail Python package:
pip install ckanext-datasetthumbnail
  1. Add datasetthumbnail to the ckan.plugins setting in your CKAN config file.

  2. Restart CKAN.

Config Settings

# Show thumbnails (optional, default: False)
ckan.datasetthumbnail.show_thumbnail = True

# Autogenerate thumbnails (optional, default: False)
ckan.datasetthumbnail.auto_generate = True

# Generated thumbnail width (optional, default: 140)
ckan.datasetthumbnail.thumbnail_width = 140

# Generated thumbnail height (optional, default: int(width * 1.415))
ckan.datasetthumbnail.thumbnail_height = 140

About

Copyright (c) 2016 MapAction. Developed by Aptivate.

Development of v1 of this plugin was funded by ECHO (European Commission Humanitarian Aid).

License

This extension is licensed under the AGPL-3.0 license.

Version
1.0.0
Version release date
2016-07-11
Contact name
Aptivate
Contakt email
(not set)
Contact Url
(not set)


Installation Guide

Configuration hints

Requires Pillow with PngImagePlugin and JpegImagePlugin. Available on PyPI.

Plugins to configure (ckan.ini)
datasetthumbnail
CKAN Settings (ckan.ini)
# ckan.datasetthumbnail.show_thumbnail = True
# ckan.datasetthumbnail.auto_generate = True
# ckan.datasetthumbnail.thumbnail_width = 140
# ckan.datasetthumbnail.thumbnail_height = 140
DB migration to be executed
(not set)
<< back to Extensions