Skip to content

Commit 4765b1a

Browse files
committed
adding command to generate thumbnails
1 parent 6570607 commit 4765b1a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

ckeditor/management/__init__.py

Whitespace-only changes.

ckeditor/management/commands/__init__.py

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Creates thumbnail files for the CKEditor file image browser. Useful if starting
3+
to use django-ckeditor with existing images.
4+
"""
5+
6+
import os
7+
8+
from django.core.management.base import NoArgsCommand
9+
10+
from ckeditor.views import (get_image_files, get_thumb_filename,
11+
create_thumbnail)
12+
13+
14+
class Command(NoArgsCommand):
15+
def handle_noargs(self, **options):
16+
for image in get_image_files():
17+
if not os.path.isfile(get_thumb_filename(image)):
18+
print "Creating thumbnail for %s" % image
19+
try:
20+
create_thumbnail(image)
21+
except Exception, e:
22+
print "Couldn't create thumbnail for %s: %s" % (image, e)
23+
print "Finished"

0 commit comments

Comments
 (0)