Skip to content

Commit

Permalink
ZO-6370: add size and aspect ratio to image grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinnaj94 committed Nov 12, 2024
1 parent 6a56c92 commit d5b3a6f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
9 changes: 6 additions & 3 deletions core/src/zeit/content/article/edit/image_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ def __init__(self, context, xml):
show_caption = ObjectPathAttributeProperty(
'.', 'show_caption', zeit.content.article.edit.interfaces.IImageGrid['show_caption']
)
images = zeit.cms.content.reference.MultiResource('.body.image', 'image')
rows = ObjectPathAttributeProperty(
'.row', 'rows', zeit.content.article.edit.interfaces.IImageGrid['rows']
size = ObjectPathAttributeProperty(
'.', 'size', zeit.content.article.edit.interfaces.IImageGrid['size']
)
aspect_ration = ObjectPathAttributeProperty(
'.', 'aspect_ration', zeit.content.article.edit.interfaces.IImageGrid['aspect_ration']
)
images = zeit.cms.content.reference.MultiResource('.body.image', 'image')

# first_image = zeit.cms.content.reference.SingleResource('.image[1]', 'image')
# second_image = zeit.cms.content.reference.SingleResource('.image[2]', 'image')
Expand Down
35 changes: 28 additions & 7 deletions core/src/zeit/content/article/edit/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,19 +655,40 @@ class IIngredientDice(IBlock):
pass


class ImageGridSizeSource(zeit.cms.content.sources.SimpleDictSource):
values = {
'small': _('Small'),
'medium': _('Medium'),
'large': _('Large'),
}


class ImageGridAspectRationSource(zeit.cms.content.sources.SimpleDictSource):
values = {
'2-3': _('2:3'),
'3-2': _('3:2'),
'4-3': _('4:3'),
}


class IImageGrid(IBlock):
show_caption = zope.schema.Bool(title=_('Show caption'), required=False, default=True)
size = zope.schema.Choice(
title=_('Size'),
source=ImageGridSizeSource(),
default='medium',
required=True,
)
aspect_ration = zope.schema.Choice(
title=_('Aspect ration'),
source=ImageGridAspectRationSource(),
default='2-3',
required=True,
)
images = zope.schema.Tuple(
title=_('Images'),
default=(),
max_length=3,
required=False,
value_type=zope.schema.Choice(source=zeit.content.image.interfaces.ImageGroupSource()),
)
rows = zope.schema.Tuple(
title=_('Rows'),
default=(),
max_length=3,
required=False,
value_type=zope.schema.TextLine(),
)

0 comments on commit d5b3a6f

Please sign in to comment.