Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix to size_to_nearest
  • Loading branch information
coleifer committed Apr 22, 2011
1 parent 193d896 commit 9a23c93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions oembed/tests/tests/utils.py
Expand Up @@ -19,6 +19,9 @@ def test_size_to_nearest(self):
# that is defined
self.assertEqual((100, 100), size_to_nearest(150, None, sizes, True))
self.assertEqual((100, 100), size_to_nearest(None, 150, sizes, True))
self.assertEqual((200, 200), size_to_nearest(220, None, sizes, True))
self.assertEqual((200, 200), size_to_nearest(None, 220, sizes, True))


# if both dimensions are None use the largest possible
self.assertEqual((300, 300), size_to_nearest(None, None, sizes, False))
Expand Down
4 changes: 2 additions & 2 deletions oembed/utils.py
Expand Up @@ -26,12 +26,12 @@ def size_to_nearest(width=None, height=None, allowed_sizes=OEMBED_ALLOWED_SIZES,
if width:
width = int(width) > minwidth and int(width) or minwidth
elif force_fit:
width = minwidth
width = maxwidth

if height:
height = int(height) > minheight and int(height) or minheight
elif force_fit:
height = minheight
height = maxheight

for size in sorted(allowed_sizes):
if width and not height:
Expand Down

0 comments on commit 9a23c93

Please sign in to comment.