[close #141] Fix checking if thumbnail exists in management command.
This commit is contained in:
parent
8fe3c51662
commit
ca89d42126
|
@ -17,7 +17,7 @@ class Command(NoArgsCommand):
|
|||
if getattr(settings, 'CKEDITOR_IMAGE_BACKEND', None):
|
||||
backend = get_backend()
|
||||
for image in get_image_files():
|
||||
if not os.path.isfile(get_thumb_filename(image)):
|
||||
if not self._thumbnail_exists(image):
|
||||
self.stdout.write("Creating thumbnail for %s" % image)
|
||||
try:
|
||||
backend.create_thumbnail(image)
|
||||
|
@ -26,3 +26,13 @@ class Command(NoArgsCommand):
|
|||
self.stdout.write("Finished")
|
||||
else:
|
||||
self.stdout.write("No thumbnail backend is enabled")
|
||||
|
||||
def _thumbnail_exists(self, image_path):
|
||||
thumb_path = self._to_absolute_path(
|
||||
get_thumb_filename(image_path)
|
||||
)
|
||||
return os.path.isfile(thumb_path)
|
||||
|
||||
@staticmethod
|
||||
def _to_absolute_path(image_path):
|
||||
return os.path.join(settings.MEDIA_ROOT, image_path)
|
||||
|
|
Loading…
Reference in New Issue