Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
add more s3 info and feincms_thumbnail override
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Baechler committed Jan 15, 2015
1 parent 328b174 commit dd85e3c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fbox/utils/feincms_sorl_thumbnailer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# coding: utf-8
"""
Thumbnailer class for FeinCMS.
Allows using sorl thumbnail as default thumbnailer.
Use this if you have mediafiles stored on S3.
Add this line to your settings:
FEINCMS_MEDIALIBRARY_THUMBNAIL = 'feincms_sorl_thumbnailer.thumbnailer'
"""
from __future__ import unicode_literals
from sorl.thumbnail import get_thumbnail


def thumbnailer(mediafile, dimensions='100x100', quality=65, **kwargs):
"""
Function called by FeinCMS medialibrary.thumbnail.admin_thumbnail
:param mediafile: - the mediafile object
:param kwargs: - options passed to the thumbnailer
:return: - URL of the thumbnail
"""
if mediafile.type == 'image':
im = get_thumbnail(mediafile.file, dimensions, quality=quality)
return im.url
return ''
13 changes: 13 additions & 0 deletions fbox/utils/s3utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
"""
Custom S3 storage backends to store files in subfolders.
Use this backend with the boto storage app.
Make sure you use an alternative thumbnailer class for FeinCMS, such as
feincms_sorl_thumbnailer.
Use these settings for S3:
AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = 'iraqiodyssee'
AWS_LOCATION = '/media/'
AWS_QUERYSTRING_EXPIRE = 60*60*48
AWS_S3_FILE_OVERWRITE = False
"""

from storages.backends.s3boto import S3BotoStorage
Expand Down

0 comments on commit dd85e3c

Please sign in to comment.