Resize image at upload

Fix #271
This commit is contained in:
Jean-Marie Favreau 2025-03-01 13:05:31 +01:00
parent 33983afeca
commit 571a6775c4
4 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 4.2.9 on 2025-03-01 13:04
from django.db import migrations
import django_resized.forms
class Migration(migrations.Migration):
dependencies = [
('agenda_culturel', '0149_alter_recurrentimport_processor'),
]
operations = [
migrations.AlterField(
model_name='event',
name='local_image',
field=django_resized.forms.ResizedImageField(blank=True, crop=None, force_format='JPEG', keep_meta=True, max_length=1024, null=True, quality=75, scale=0.5, size=[900, None], upload_to='', verbose_name='Illustration'),
),
]

View File

@ -18,6 +18,7 @@ from django.contrib.sites.models import Site
from django.core.mail import send_mail
from django.template.loader import render_to_string
from autoslug import AutoSlugField
from django_resized import ResizedImageField
import uuid
@ -718,7 +719,8 @@ class Event(models.Model):
blank=True
)
local_image = models.ImageField(
local_image = ResizedImageField(
size=[900, None],
verbose_name=_("Illustration"),
max_length=1024,
blank=True,

View File

@ -313,3 +313,12 @@ DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.profiling.ProfilingPanel',
"template_profiler_panel.panels.template.TemplateProfilerPanel",
]
DJANGORESIZED_DEFAULT_SIZE = [1200, 1200]
DJANGORESIZED_DEFAULT_SCALE = 0.5
DJANGORESIZED_DEFAULT_QUALITY = 75
DJANGORESIZED_DEFAULT_KEEP_META = True
DJANGORESIZED_DEFAULT_FORCE_FORMAT = 'JPEG'
DJANGORESIZED_DEFAULT_FORMAT_EXTENSIONS = {'JPEG': ".jpg"}
DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = True

View File

@ -49,3 +49,4 @@ django-debug-toolbar-template-profiler==2.1.0
requests==2.32.3
django-cleanup==9.0.0
django-unused-media==0.2.2
django-resized==1.0.3