Skip to content

powderflask/cms-thumbnail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django CMS Thumbnail

CMS Thumbnail exposes sorl-thumbnail's image processing and caching functionality within Django CMS.

Currently in development - DO NOT USE for production sites!

NOTE: Requires fix for django-cms issue #588 (hopefully in trunk soon).

Features

  • Named "presets" define image processing rules (image geometry and options).
  • Content editors can choose which preset to display image with (or even define their own presets)
  • Picutre plugin extends and replaces the django-cms Picture plugin to add an thumbnail preset.
  • Built on top of the excellent sorl-thumbnail module - provides loads of flexibility and extensibility.

Dependencies

  • django-cms 2.1+
  • sorl-thumbnail 10.12+
  • python 2.5.2+ (required by sorl-thumbnail)

License

Copyright (C) 2010 Driftwood Cove Designs

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details

You are free to copy, use, or modify this software in any way you like, but please provide attribution to the original author with a link to: https://github.com/powderflask/cms-thumbnail

Author

Driftwood Cove Designs

Known Issues

see: https://github.com/powderflask/cms-thumbnail/issues

Installation

From PyPI

not yet - sorry.

Manual Download

You can download a zipped archive from http://github.com/powderflask/cms-thumbnail/downloads.

Unzip the file you downloaded. Then go in your terminal and cd into the unpacked folder. Then type python setup.py install in your terminal.

Configuration

Add the base module and one or more plugins to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = (..., 
    'cms_thumbnail',            # installs Preset model
    'cms_thumbnail.plugins.*',  # installs all thumbnail plugins
)  

OR pick and choose:

INSTALLED_APPS = (...,
    'cms_thumbnail.plugins.picture',  # use this instead of 'cms.plugins.picture'
    'cms_thumbnail.plugins.image',
)

Don't forget to syncdb.

Templates

Recommended to use the app_directories template loader:

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    ...
)

If you aren't using the app_directories template loader, you will need to add the templates to your TEMPLATE_DIRS settings. The templates are at:

cms_thumbnail/plugins/<plugin-name>/templates

and can be overridden by adding a "cms_thumbnail" folder to your project templates directory.

Settings

No settings specific for cms thumbnail, but do see sorl-thumbnail for important settings.

Presets

A preset defines a set of image processing operations, which might include scaling, cropping, etc. The available operations are defined by sorl-thumbnail (see sorl-thumbnail documentation). A preset is composed of two fields:

These definitions are passed directly through to sorl-thumbnail without interpretation. In turn, sorl-thumbnail passes the options directly through to the backend image library engine, which provides enormous flexibility and extensibility.

Template Tags

Use either sorl-thumbnail's template tag, and pass the preset fields through:

{% load thumbnail %}
{% thumbnail source preset.geometry options=preset.options as var %}

OR, equivalently, use the cms_thumbnail template tag, which simplifies the syntax:

{% load cms_thumbnail %}
{% thumbnail source preset as var %}

Both the thumbnail tags have an optional {% empty %} tag, which renders if the source resolves to an empty value.

Margin Filter

There is also a margin filter which exposes the sorl-thumbnail margin filter. It simply takes a preset object or preset name as a parameter and delegates to the sorl-thumbnail margin filter using the preset geometry:

{% load cms_thumbnail %}
{% thumbnail profile.photo profile.preset as im %}
     <img src="{{ im.url }}" style="margin:{{ im|margin:profile.preset }}">
{% endthumbnail %}

The two tag libraries do conflict, so use one or the other in any given template.

Kudos

About

Uses sorl-thumbnail to bring Drupal's imagecache-like behaviour to django-cms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages