This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

flask-thumbnails

A simple extension to create a thumbs for the Flask

Installation

Install with pip:

Run pip install git+https://github.com/gbea/flask-thumbs.git

Add Thumbnail to your extension file:

from flask.ext.thumbnails import Thumbnail

app = Flask(__name__)

thumb = Thumbnail(app)

Add MEDIA_FOLDER and MEDIA_URL in your settings:

app.config['MEDIA_FOLDER'] = '/home/www/media'
app.config['MEDIA_URL'] = '/media/'

Example usage

Use in Jinja2 template:

<img src="{{ 'image.jpg'|thumbnail('200x200') }}" alt="" />
<img src="{{ 'image.jpg'|thumbnail('200x200', crop='fit', quality=100) }}" alt="" />

Options

crop='fit' returns a sized and cropped version of the image, cropped to the requested aspect ratio and size, read more.

quality=XX changes the quality of the output JPEG thumbnail, default 85.

Develop and Production

Production

In production, you need to add media directory in you web server.

Develop

To service the uploaded files need a helper function, where /media/ your settings app.config['MEDIA_URL']:

from flask import send_from_directory

@app.route('/media/<regex("([\w\d_/-]+)?.(?:jpe?g|gif|png)"):filename>')
def media_file(filename):
    return send_from_directory(app.config['MEDIA_THUMBNAIL_FOLDER'], filename)

Option settings

If you want to store the thumbnail in a folder other than the MEDIA_FOLDER, you need to set it manually:

app.config['MEDIA_THUMBNAIL_FOLDER'] = '/home/www/media/cache'
app.config['MEDIA_THUMBNAIL_URL'] = '/media/cache/'

Acknowledgements

Much of the code here is based on flask-thumbnails by Dmitriy Sokolov:

https://github.com/silentsokolov/flask-thumbnails

Many thanks to the author and contributors of flask-thumbnails, for the foundation of this codebase, and for the generous license terms that allow forks like this.

Release History

Release History

1.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
flask-thumbs-1.2.tar.gz (3.7 kB) Copy SHA256 Checksum SHA256 Source Oct 29, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting