Skip to content

Instantly share code, notes, and snippets.

@shadowmint
Created August 11, 2014 02:06
Show Gist options
  • Save shadowmint/a150df416660fe18fcd5 to your computer and use it in GitHub Desktop.
Save shadowmint/a150df416660fe18fcd5 to your computer and use it in GitHub Desktop.
Plone helper
def url(self, image, width=None, height=None):
"""Generate a scaled image url from the given values """
if width is None:
width = image.width
if height is None:
height = image.height
scales = image.restrictedTraverse('@@images')
scaled_image = scales.scale(
'image',
width=width,
height=height,
direction='down',
quality=85
)
return scaled_image.absolute_url()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment