Created
August 11, 2014 02:06
-
-
Save shadowmint/a150df416660fe18fcd5 to your computer and use it in GitHub Desktop.
Plone helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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