New answers tagged

1

Craft has a newer asset method called getSrcset which should be close to what you need. Here's the code example from the docs: {% do asset.setTransform({ width: 300, height: 300 }) %} {{ tag('img', { src: asset.url, width: asset.width, height: asset.height, srcset: asset.getSrcset(['1.5x', '2x', '3x']), alt: asset.title, }) }} You can also skip ...


2

You can write a function, a utility template or a macro to make repetitive tasks like generating responsive images easier. I usually prefer templates, because they're easy to extend and they can take a lot of optional arguments without the user needing to pass all of them. Building your own utility templates is a good time investments, since you can create a ...


Top 50 recent answers are included