add support for svg images in library
This commit is contained in:
parent
2c217939b0
commit
ff3a09d30c
7 changed files with 257 additions and 30 deletions
|
@ -59,11 +59,17 @@ class ImageLibraryWidget(forms.Select):
|
|||
selected = "selected" if str(image.pk) == str(value) else ""
|
||||
image_url = image.image.url if image.image else ""
|
||||
|
||||
# Use img tag for all images in widget to maintain clickability
|
||||
# SVG files will still display correctly with img tag
|
||||
preview_html = (
|
||||
f'<img src="{image_url}" alt="{image.alt_text}" loading="lazy">'
|
||||
)
|
||||
|
||||
html_parts.append(
|
||||
f"""
|
||||
<div class="image-option {selected}" data-value="{image.pk}">
|
||||
<div class="image-preview">
|
||||
<img src="{image_url}" alt="{image.alt_text}" loading="lazy">
|
||||
{preview_html}
|
||||
</div>
|
||||
<div class="image-info">
|
||||
<span class="image-name">{image.name}</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue