diff --git a/easy_thumbnails/files.py b/easy_thumbnails/files.py index 79652796..5d59ade0 100644 --- a/easy_thumbnails/files.py +++ b/easy_thumbnails/files.py @@ -76,7 +76,7 @@ def get_thumbnailer(obj, relative_name=None): remote_source=obj is not None) -def generate_all_aliases(fieldfile, include_global): +def generate_all_aliases(fieldfile, include_global, force=False): """ Generate all of a file's aliases. @@ -84,12 +84,14 @@ def generate_all_aliases(fieldfile, include_global): :param include_global: A boolean which determines whether to generate thumbnails for project-wide aliases in addition to field, model, and app specific aliases. + :param force: Force the generation behaviour by setting the generate param + to either True or False as required. """ all_options = aliases.all(fieldfile, include_global=include_global) if all_options: thumbnailer = get_thumbnailer(fieldfile) for options in all_options.values(): - thumbnailer.get_thumbnail(options) + thumbnailer.get_thumbnail(options, force=force) def database_get_image_dimensions(file, close=False, dimensions=None): @@ -484,7 +486,7 @@ def get_existing_thumbnail(self, thumbnail_options, high_resolution=False): thumbnail_file.set_image_dimensions(exists) return thumbnail_file - def get_thumbnail(self, thumbnail_options, save=True, generate=None, + def get_thumbnail(self, thumbnail_options, save=True, generate=None, force=False, silent_template_exception=False): """ Return a ``ThumbnailFile`` containing a thumbnail. @@ -498,6 +500,9 @@ def get_thumbnail(self, thumbnail_options, save=True, generate=None, Force the generation behaviour by setting the ``generate`` param to either ``True`` or ``False`` as required. + Force re-generation behaviour (even if thumbnail already exists) by setting + the force param to either True or False as required. + The new thumbnail image is generated using the ``thumbnail_options`` dictionary. If the ``save`` argument is ``True`` (default), the generated thumbnail will be saved too. @@ -507,7 +512,7 @@ def get_thumbnail(self, thumbnail_options, save=True, generate=None, generate = self.generate thumbnail = self.get_existing_thumbnail(thumbnail_options) - if not thumbnail: + if force or not thumbnail: if generate: thumbnail = self.generate_thumbnail( thumbnail_options,