Permalink
Browse files

Merge branch 'master' of github.com:Pylons/Kotti

  • Loading branch information...
2 parents f1c5e9c + b75b81a commit a779e2d888454f4841592722106ea11aa27b2c8a @dnouri dnouri committed May 24, 2012
Showing with 2 additions and 82 deletions.
  1. +1 −5 docs/cookbook/images.rst
  2. +0 −60 kotti/tests/browser-image.txt
  3. +1 −17 kotti/views/image.py
View
@@ -3,11 +3,7 @@ Image URLs
Kotti provides on-the-fly image scaling by utilizing `plone.scale`_.
-Images (including arbitrary scales) can be referenced by this URL schema: ``/path/to/image_content_object/image[[/<image_scale>]/download]`` where ``<image_scale>`` can be:
-
- - a predefined image scale (see below)
- - a string of the form ``<max_width>x<max_height>`` or
- - a URL path segment of the form ``<max_width>/<max_height>``
+Images can be referenced by this URL schema: ``/path/to/image_content_object/image[/<image_scale>]/download]`` where ``<image_scale>`` is a predefined image scale (see below).
If the last URL path segment is ``download``, the image will be served with ``Content-disposition: attachment`` otherwise it will be served with ``Content-disposition: inline``.
@@ -137,46 +137,6 @@ Span1, attachment
>>> browser.headers["content-disposition"].lower()
'attachment;filename="sendeschluss.jpg"'
-300x200 as string
-
- >>> browser.open(testing.BASE_URL + '/my-gallery/image-1/image/300x200')
- >>> browser.headers["content-type"]
- 'image/jpeg'
- >>> 15000 < int(browser.headers["content-length"]) < 25000
- True
- >>> browser.headers["content-disposition"].lower()
- 'inline;filename="sendeschluss.jpg"'
-
-300x200 as string, attachment
-
- >>> browser.open(testing.BASE_URL + '/my-gallery/image-1/image/300x200/download')
- >>> browser.headers["content-type"]
- 'image/jpeg'
- >>> 15000 < int(browser.headers["content-length"]) < 25000
- True
- >>> browser.headers["content-disposition"].lower()
- 'attachment;filename="sendeschluss.jpg"'
-
-300x200 as separate URL path segments
-
- >>> browser.open(testing.BASE_URL + '/my-gallery/image-1/image/300/200')
- >>> browser.headers["content-type"]
- 'image/jpeg'
- >>> 15000 < int(browser.headers["content-length"]) < 25000
- True
- >>> browser.headers["content-disposition"].lower()
- 'inline;filename="sendeschluss.jpg"'
-
-300x200 as separate URL path segments, attachment
-
- >>> browser.open(testing.BASE_URL + '/my-gallery/image-1/image/300/200/download')
- >>> browser.headers["content-type"]
- 'image/jpeg'
- >>> 15000 < int(browser.headers["content-length"]) < 25000
- True
- >>> browser.headers["content-disposition"].lower()
- 'attachment;filename="sendeschluss.jpg"'
-
Invalid predefined scale (should return original size)
>>> browser.open(testing.BASE_URL + '/my-gallery/image-1/image/invalid_scale')
@@ -197,23 +157,3 @@ Invalid predefined scale (should return original size), attachment
>>> browser.headers["content-disposition"].lower()
'attachment;filename="sendeschluss.jpg"'
-Invalid URL path segment scale (should return original size)
-
- >>> browser.open(testing.BASE_URL + '/my-gallery/image-1/image/width/height')
- >>> browser.headers["content-type"]
- 'image/jpeg'
- >>> browser.headers["content-length"]
- '107341'
- >>> browser.headers["content-disposition"].lower()
- 'inline;filename="sendeschluss.jpg"'
-
-Invalid URL path segment scale (should return original size), attachment
-
- >>> browser.open(testing.BASE_URL + '/my-gallery/image-1/image/width/height/download')
- >>> browser.headers["content-type"]
- 'image/jpeg'
- >>> browser.headers["content-length"]
- '107341'
- >>> browser.headers["content-disposition"].lower()
- 'attachment;filename="sendeschluss.jpg"'
-
View
@@ -70,6 +70,7 @@ def view(self):
def image(self):
"""return the image in a specific scale, either inline (default) or as attachment"""
+ width, height = (None, None)
subpath = list(self.request.subpath)
if (len(subpath) > 0) and (subpath[-1] == "download"):
@@ -83,23 +84,6 @@ def image(self):
if scale in image_scales:
# /path/to/image/scale/thumb
width, height = image_scales[scale]
- else:
- # /path/to/image/scale/160x120
- try:
- width, height = [int(v) for v in scale.split("x")]
- except ValueError:
- width, height = (None, None)
-
- elif len(subpath) == 2:
- # /path/to/image/scale/160/120
- try:
- width, height = [int(v) for v in subpath]
- except ValueError:
- width, height = (None, None)
-
- else:
- # don't scale at all
- width, height = (None, None)
if width and height:
image, format, size = scaleImage(self.context.data,

0 comments on commit a779e2d

Please sign in to comment.