I'm currently using a route to get a specific asset for a gallery section of my site. URL is similiar to http://craft.dev/place/place-name/gallery/1 (Where 1 is the number in the gallery.)
I'm currently doing the following in the template
{% extends '_layout' %}
{% set entry = craft.entries.slug(craft.request.getSegment(2)).first() %}
{% set image = entry.images[craft.request.getSegment(4) - 1] %}
{% block content %}
{{image.getImg('featuredImage')}}
{% endblock %}
It works currently but is there a cleaner way to do it without the - 1?
first()and in all other empty parameters? – carlcs Jun 14 '14 at 21:24file.nth(n)would be quite useful! – Seán O'Grady Jun 14 '14 at 21:30nth()idea. Adding to the list :) – Brandon Kelly Jun 14 '14 at 21:31nth()function made it into Craft 2.2 ;) – Brandon Kelly Sep 02 '14 at 19:46