Skip to content

Commit 41be735

Browse files
erralstevepiercy
andauthored
Apply suggestions from code review
Co-authored-by: Steve Piercy <web@stevepiercy.com>
1 parent de4c763 commit 41be735

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

plone/namedfile/usage.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -468,24 +468,25 @@ space is provided in the attribute ``sizes``.
468468

469469
So one can do the following:
470470

471+
.. code-block:: xml
472+
471473
<img tal:define="images context/@@images;"
472474
tal:replace="structure python:images.srcset(sizes='90vw')" />
473475
474476
475477
This will render the ``img`` with the URLs of all scales configured in Plone, calculating the width
476478
of each of the scales and will add the ``sizes="90vw"`` attribute.
477479
The ``sizes`` attribute instructs the browser to render
478-
the image that best fits as it will take the 90% of the current viewport-width" whichever is the current
479-
viewport.
480+
the image that best fits, as it will take 90% of the current viewport width.
481+
482+
This means that, for bigger screens, the browser will download a bigger scaled image, while for smaller screens, a smaller scaled image is enough.
480483

481-
This will mean that for bigger screens the browser will download a bigger image while in small screens
482-
a smaller scale is enough.
484+
This also means that the developer does not need to worry about creating a specific scale.
485+
They only need to provide the correct media query to signal the required width.
483486

484-
This also means that the developer does not need to worry on creating a specific scale, they only need to
485-
provide the correct media query to signal the required width.
487+
The ``scrset`` method of the ``@@images`` view also takes all other parameters that can be rendered in the ``img`` tag, such as ``title``, ``alt``, or ``loading``:
486488

487-
The `scrset` method of the `@@images` view takes also all other parameters that can be rendered in the `img`
488-
tag such as `title`, `alt` or `loading`:
489+
.. code-block:: xml
489490
490491
491492
<img tal:define="images context/@@images;"
@@ -495,6 +496,7 @@ tag such as `title`, `alt` or `loading`:
495496
css_class='rounded-img')" />
496497
497498
498-
*NOTE*: while using this approach may be useful for projects, using it in reusable addons is not recommended
499-
because it may require overriding it to your needs in a project. For such cases, we recommend using configurable
500-
picture variants.
499+
.. note::
500+
501+
While using this approach may be useful for projects, using it in reusable add-ons is not recommended, because it may require overriding it to your needs in a project.
502+
For such cases, use configurable picture variants instead.

0 commit comments

Comments
 (0)