.. include:: /Includes.rst.txt
.. _usage:
=====
Usage
=====
This chapter shows practical examples for integrating
responsive images into your Fluid templates.
.. _usage-namespace:
Register the namespace
======================
Add the ViewHelper namespace at the top of your Fluid
template or register it globally:
.. code-block:: html
:caption: Inline namespace declaration
{namespace nr=Netresearch\NrImageOptimize\ViewHelpers}
.. _usage-basic-example:
Basic responsive image
======================
.. code-block:: html
:caption: Simple responsive image with quality setting
.. _usage-responsive-srcset:
Responsive width-based srcset
=============================
Enable width-based ``srcset`` generation with a ``sizes``
attribute for improved responsive image handling. This is
opt-in per usage.
.. code-block:: html
:caption: Enable responsive srcset with default variants
.. _usage-custom-variants:
Custom width variants
---------------------
.. code-block:: html
:caption: Specify custom breakpoints for srcset
.. _usage-output-comparison:
Output comparison
=================
**Legacy mode** (``responsiveSrcset=false`` or not set):
.. code-block:: html
:caption: Density-based 2x srcset output
**Responsive mode** (``responsiveSrcset=true``):
.. code-block:: html
:caption: Width-based srcset output
.. _usage-fetchpriority:
Fetch priority for Core Web Vitals
===================================
Use the ``fetchpriority`` attribute to hint the browser
about resource prioritization, improving Largest Contentful
Paint (LCP) scores:
.. code-block:: html
:caption: High priority for above-the-fold hero image