Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from plone.tiles import Tile
from plone.app.z3cform.widget import RelatedItemsFieldWidget
from plone.app.standardtiles.image import image_scales
from plone.autoform import directives as form
from plone.supermodel import model
from zope import schema
from zope.component import getMultiAdapter
from zope.component.hooks import getSite
from zope.globalrequest import getRequest
from zope.interface import Invalid
from zope.interface import invariant
class ImageTile(Tile):
def get_image(self):
# logic to get image from data
pass
class IImageTileSchema(model.Schema):
form.widget(image=RelatedItemsFieldWidget)
image = schema.List(
title=u"Image",
description=u"Reference image on the site.",
required=True,
default=[],
value_type=schema.Choice(
vocabulary='plone.app.vocabularies.Catalog'
)
)
@invariant
def validate_image(data):
pass
scale = schema.Choice(
title=u'Scale',
required=True,
source=image_scales,
default=u'large'
)
caption = schema.TextLine(
title=u'Caption',
required=False
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment