1

Is there a way to reverse the Assets field keeping the fixed order? I've tried a couple of things:

myAssetsField.order('fixedOrder desc') //breaks
myAssetsField.order('id desc') // wrong, since they're not sorted by id
myAssetsField.reverse() // does nothing

Any ideas?

4

You could try twig's reverse filter.

{% for asset in entry.assetsField|reverse %}
    <img src="{{ asset.url }}" alt="{{ asset.title }}"/>
{% endfor %}
3

Set the order parameter to 'sortOrder desc':

{% set assets = myAssetsField.order('sortOrder desc') %}
2
  • The value isn't in the list of possible values in the Craft docs, but I will make P&T aware of this.
    – carlcs
    Feb 3 '15 at 9:13
  • Ah. That's the sort parameter I was looking for. Marked Douglas' answer as accepted just because he was 3 minutes earlier, and both answers work. (And he has less rep than you)
    – peirix
    Feb 3 '15 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.