Speedup inlines using autocomplete field and add more previews (#38)

This commit is contained in:
2024-11-04 11:33:28 +01:00
committed by GitHub
parent 456272b93a
commit d0854a4cff
8 changed files with 21 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
from ram.utils import git_suffix
__version__ = "0.12.5"
__version__ = "0.13.0"
__version__ += git_suffix(__file__)

View File

@@ -36,8 +36,8 @@ class Image(models.Model):
storage=DeduplicatedStorage,
)
def image_thumbnail(self):
return get_image_preview(self.image.url)
def image_thumbnail(self, max_size=150):
return get_image_preview(self.image.url, max_size)
image_thumbnail.short_description = "Preview"

View File

@@ -44,10 +44,10 @@ def git_suffix(fname):
return gh
def get_image_preview(url):
def get_image_preview(url, max_size=150):
return format_html(
'<img src="%s" style="max-width: 150px; max-height: 150px;'
'background-color: #eee;" />' % url
'<img src="{src}" style="max-width: {size}px; max-height: {size}px;'
'background-color: #eee;" />'.format(src=url, size=max_size)
)