New answers tagged


To explicitly outputting a webp image: <source type="image/webp" srcset="{{ asset.getUrl({ transform: 'myNamedTransform', format: 'webp', }) }}">


Caveat: This is totally untested, and could be nonsense. I'm sure you'll let me know. It assumes that the Craft element query methods can be used here. If you have a 'lang' value, add a where to your basic assets element query {% set folderId ='folderId') %} {% set query ='q') %} {%...


Have you tried the $element->isFieldDirty() method, or checking through the $element->dirtyFields array for your asset field, rather than checking revision dates? There may be a good reason why you're not using those, but I thought I'd suggest it in case you hadn't considered it.


With the correct cache busting, files can remained cached for as long as possible. Craft handles a lot of this for you. I typically cache items for a year but do take caution to ensure every reference to assets within the site has a cache busting string on it. It's important to note that Cloudfront needs to be setup to use these query strings. On the ...


There's a couple different ways to handle this. Base URL on Asset Volume One way is just to treat the asset volume like you might a CDN. Unlike other CMS (ahem WP), Craft doesn't hardcode URLs into the database and will build them up on-the-fly. On the local dev server, you just need to set the base url (i.e. server name) of a volume to that of the ...


You're close! Because an asset field can potentially contain multiple items you need to explicitly select the first one, so: {% set video = %} But that doesn't get the actual url of the video, to get that you need to request it: {{ video.url() }} So in your case: {% set video = %} {% if video %} <video width=&...

Top 50 recent answers are included