mirror of
https://github.com/pinry/pinry.git
synced 2025-11-15 17:35:50 +01:00
Remove /by-md5/ prefix from image paths
Use forked django-images for now, until we can communicate with the upstream about it. Fixes #4
This commit is contained in:
16
pinry/core/utils.py
Normal file
16
pinry/core/utils.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
def upload_path(instance, filename, **kwargs):
|
||||
hasher = hashlib.md5()
|
||||
for chunk in instance.image.chunks():
|
||||
hasher.update(chunk)
|
||||
hash = hasher.hexdigest()
|
||||
base, ext = os.path.splitext(filename)
|
||||
return '%(first)s/%(second)s/%(hash)s/%(base)s%(ext)s' % {
|
||||
'first': hash[0],
|
||||
'second': hash[1],
|
||||
'hash': hash,
|
||||
'base': base,
|
||||
'ext': ext,
|
||||
}
|
||||
@@ -90,6 +90,7 @@ INSTALLED_APPS = (
|
||||
'pinry.users',
|
||||
)
|
||||
|
||||
IMAGE_PATH = 'pinry.core.utils.upload_path'
|
||||
IMAGE_SIZES = {
|
||||
'thumbnail': {'size': [240, 0]},
|
||||
'standard': {'size': [600, 0]},
|
||||
|
||||
@@ -6,5 +6,5 @@ django-braces
|
||||
mock
|
||||
factory-boy
|
||||
django_compressor
|
||||
http://github.com/mirumee/django-images/tarball/master#egg=django-images
|
||||
http://github.com/kklimonda/django-images/tarball/master#egg=django-images
|
||||
http://github.com/hcarvalhoalves/django-taggit/tarball/master#egg=django-taggit
|
||||
|
||||
12
setup.py
12
setup.py
@@ -8,18 +8,18 @@ def read(fname):
|
||||
|
||||
dependency_links = [
|
||||
# Not released version, PIL dependency replaced by pillow
|
||||
'http://github.com/mirumee/django-images/tarball/master#egg=django-images-2013.1.99',
|
||||
'http://github.com/kklimonda/django-images/tarball/master#egg=django-images-2013.1.99',
|
||||
# Original project has been dead for years, this branch adds Django 1.4 support
|
||||
'http://github.com/hcarvalhoalves/django-taggit/tarball/master#egg=django-taggit-0.9.3.99'
|
||||
]
|
||||
|
||||
install_requires = [
|
||||
'Django>=1.5',
|
||||
'Pillow'
|
||||
'South'
|
||||
'django-tastypie'
|
||||
'django-braces'
|
||||
'django_compressor'
|
||||
'Pillow',
|
||||
'South',
|
||||
'django-tastypie',
|
||||
'django-braces',
|
||||
'django_compressor',
|
||||
'django-images>=2013.1.99',
|
||||
'django-taggit>=0.9.3.99'
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user