Browse Source

feat(images): diversifie les tailles d image incrustees au texte

master
François Poulain 4 months ago
parent
commit
02362ac198
2 changed files with 30 additions and 0 deletions
  1. +10
    -0
      assets/scss/components/_richtext.scss
  2. +20
    -0
      biohdf/base/image_formats.py

+ 10
- 0
assets/scss/components/_richtext.scss View File

@@ -7,6 +7,11 @@
max-width: 33%;
height: auto;
margin-right: 2rem;
@each $width in 33, 50, 66 {
&.w-#{$width} {
max-width: percentage($width / 100);
}
}
}

.richtext-image.right {
@@ -14,6 +19,11 @@
max-width: 33%;
height: auto;
margin-left: 2rem;
@each $width in 33, 50, 66 {
&.w-#{$width} {
max-width: percentage($width / 100);
}
}
}

.richtext-image.full-width {

+ 20
- 0
biohdf/base/image_formats.py View File

@@ -0,0 +1,20 @@
# image_formats.py
from wagtail.images.formats import (
Format,
register_image_format,
unregister_image_format,
)

unregister_image_format('left')
unregister_image_format('right')

for _sens, sens in [('left', 'gauche'), ('right', 'droite')]:
for _width, width in [('33', '1/3'), ('50', '1/2'), ('66', '2/3')]:
register_image_format(
Format(
'{}-{}'.format(_sens, _width) if _width != '33' else _sens,
'alignée à {}, largeur {}'.format(sens, width),
'richtext-image {} w-{}'.format(_sens, _width),
'width-{}'.format(1500 * int(_width) // 100),
)
)

Loading…
Cancel
Save