I am trying to access the previous and the next blog entries from my current post. Here is what I am doing
{% set params = craft.entries.section('blog').order('postDate asc') %}
{% set prevEntry = entry.getPrev(params) %}
{% set nextEntry = entry.getNext(params) %}
{# to access url, I use #}
{{ prevEntry.url }}
{# to access title, I use #}
{{ prevEntry.title }}
The above works. However, I have an asset under the field handle "featuredImage". I need to access the image URL as well as I need to apply a transform. I am not sure the code below is the most efficient way to do this. Also the image transform is giving me an error (server returns 500 error)
{% for asset in prevEntry.featuredImage %}
{% do asset.setTransform({ mode:crop, width: 200, height: 200 }) %}
<a href="{{ prevEntry.url }}"><img alt="{{ prevEntry }}" class="img-responsive center-block" src="{{ asset.url }}">
{% endfor %}
Is looping the best way to access the data considering that there is only one image? Is there a better way? Image transform is also not working (not sure why).