Skip to content

Commit

Permalink
storage_thumbnail: add method get_existing_thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Jul 20, 2023
1 parent 03b48f7 commit 1976597
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion storage_thumbnail/models/thumbnail_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _get_url_key(self, url_key):
url_key = slugify(url_key)
return url_key

def get_or_create_thumbnail(self, size_x, size_y, url_key=None):
def get_existing_thumbnail(self, size_x, size_y, url_key=None):
self.ensure_one()
url_key = self._get_url_key(url_key)
thumbnail = self.env["storage.thumbnail"].browse()
Expand All @@ -84,6 +84,10 @@ def get_or_create_thumbnail(self, size_x, size_y, url_key=None):
continue
thumbnail = th
break
return thumbnail

def get_or_create_thumbnail(self, size_x, size_y, url_key=None):
thumbnail = self.get_existing_thumbnail(size_x, size_y, url_key=url_key)
if not thumbnail and self.data:
vals = self.env["storage.thumbnail"]._prepare_thumbnail(
self, size_x, size_y, url_key
Expand Down

0 comments on commit 1976597

Please sign in to comment.