Skip to content

Commit 4c094eb

Browse files
committed
Fix container width fallback for DRF field
1 parent 0218965 commit 4c094eb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pictures/contrib/rest_framework.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def to_representation(self, obj: PictureFieldFile):
7575
try:
7676
container = int(container)
7777
except TypeError:
78-
container = None
78+
container = get_settings().CONTAINER_WIDTH
7979
except ValueError as e:
8080
raise ValueError(f"Container width is not a number: {container}") from e
8181
breakpoints = {

tests/contrib/test_rest_framework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_to_representation__with_aspect_ratios(
157157
"700": "/media/testapp/profile/image/1/700w.webp",
158158
}
159159
},
160-
"media": "(min-width: 0px) and (max-width: 991px) 100vw, (min-width: 992px) and (max-width: 1199px) 33vw, 25vw",
160+
"media": "(min-width: 0px) and (max-width: 991px) 100vw, (min-width: 992px) and (max-width: 1199px) 25vw, 400px",
161161
}
162162
},
163163
}
@@ -257,7 +257,7 @@ def test_to_representation__without_container(
257257
"700": "/media/testapp/profile/image/16_9/700w.webp",
258258
}
259259
},
260-
"media": "100vw",
260+
"media": "(min-width: 0px) and (max-width: 1199px) 100vw, 1200px",
261261
}
262262
},
263263
}

0 commit comments

Comments
 (0)