diff --git a/oembed/tests/tests/utils.py b/oembed/tests/tests/utils.py index d47101e..86fdeb3 100644 --- a/oembed/tests/tests/utils.py +++ b/oembed/tests/tests/utils.py @@ -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)) diff --git a/oembed/utils.py b/oembed/utils.py index 98deeee..68d7137 100644 --- a/oembed/utils.py +++ b/oembed/utils.py @@ -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: