Skip to content

Commit 464daea

Browse files
author
quantra
committed
Reverse the order of the sizes attr so it actually works.
+ chores.
1 parent 800140a commit 464daea

File tree

3 files changed

+262
-262
lines changed

3 files changed

+262
-262
lines changed

example/example_app/management/commands/create_expected_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.conf import settings
22
from django.core.management import BaseCommand
33

4-
from example.example_app.views import output_files_list, output_html
4+
from lazy_srcset.tests.the_test import output_files_list, output_html
55

66

77
class Command(BaseCommand):

lazy_srcset/templatetags/lazy_srcset.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def srcset(*args, **kwargs):
153153
if Path(image.name).suffix.lower() == ".svg":
154154
return svg_srcset(image)
155155

156-
# Get the conf from the first arg or default
156+
# Get the conf from the config kwarg or default
157157
try:
158158
conf = settings.LAZY_SRCSET[kwargs.pop("config")]
159159
except KeyError:
@@ -164,7 +164,7 @@ def srcset(*args, **kwargs):
164164

165165
# Set the maximum width image in our srcset.
166166
if max_width is None or max_width > image.width:
167-
# Clamp max_width to image.width or use image.width if max_width is None.
167+
# Limit max_width to image.width or use image.width if max_width is None.
168168
max_width = image.width
169169

170170
# Get the format and quality from kwargs or conf and wrap up together with source in generator_kwargs.
@@ -188,8 +188,8 @@ def srcset(*args, **kwargs):
188188
generator_image = ImageCacheFile(generator)
189189

190190
# Set the max_width image as our src and include it in the srcset.
191-
src = generator_image.url
192-
srcset = [FORMAT_STRINGS["srcset_entry"] % (generator_image.url, max_width)]
191+
src_value = generator_image.url
192+
srcset_values = [FORMAT_STRINGS["srcset_entry"] % (generator_image.url, max_width)]
193193

194194
# Set the width and height from the max_width image.
195195
width, height = generator_image.width, generator_image.height
@@ -222,15 +222,15 @@ def srcset(*args, **kwargs):
222222
generator_image = ImageCacheFile(generator)
223223

224224
# Add an entry for this image to the srcset.
225-
srcset.append(
225+
srcset_values.append(
226226
FORMAT_STRINGS["srcset_entry"] % (generator_image.url, target_width)
227227
)
228228

229229
# Create the attrs list for imminent stringification.
230230
attrs = [
231-
FORMAT_STRINGS["src"] % src,
232-
FORMAT_STRINGS["srcset"] % ", ".join(srcset),
233-
FORMAT_STRINGS["sizes"] % ", ".join(sizes),
231+
FORMAT_STRINGS["src"] % src_value,
232+
FORMAT_STRINGS["srcset"] % ", ".join(srcset_values),
233+
FORMAT_STRINGS["sizes"] % ", ".join(reversed(sizes)),
234234
FORMAT_STRINGS["width"] % width,
235235
FORMAT_STRINGS["height"] % height,
236236
]

0 commit comments

Comments
 (0)