Hot answers tagged

3

You're close! Because an asset field can potentially contain multiple items you need to explicitly select the first one, so: {% set video = component.video.one() %} 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 = component.video.one() %} {% if video %} <video width=&...


1

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 = craft.app.request.getQueryParam('folderId') %} {% set query = craft.app.request.getQueryParam('q') %} {%...


1

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.


1

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 ...


1

You can use Relations to find assets which are related to a set of entries (i.e. used in a field of the entries). Specifically, the relatedTo parameter allows you to limit an asset query to assets that are used in a specific entry or set of entries. One caveat is that you have to load the entries which contain the assets field first (at least as far as I can ...


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible