Skip to content

Commit

Permalink
Simplify working with image urls out of templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
francescortiz committed May 13, 2018
1 parent ff77124 commit 3e91ddf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion image/__init__.py
@@ -1,3 +1,3 @@
VERSION = (1, 5, 23)
VERSION = (1, 5, 24)

default_app_config = 'image.apps.ImageConfig'
8 changes: 7 additions & 1 deletion image/utils.py
Expand Up @@ -601,6 +601,12 @@ def image_tokenize(session, parameters):
return token


def image_url(session, parameters, image_field):
def image_url(session, parameters, image_field, generate=False):
if generate:
from image import views as image_views

autogen = 'autogen=true' in parameters
image_views.image(session, str(image_field), parameters, autogen)

image_path = os.path.join(image_tokenize(session, parameters), six.text_type(image_field))
return IMAGE_CACHE_STORAGE.url(image_path)

0 comments on commit 3e91ddf

Please sign in to comment.