Category field in entry I am trying to show an image that is defined on a category - named photos. I have an entry page with a list of all category entries listed at the bottom. I'd like to show this image but I'm still green on Craft categories and I'm getting errors in dev mode. This is what I have so far:

{% set entries = craft.entries.section('sermons').find() %}
{% for category, catEntries in entries | group('series.first().title') %}

 {% if category.photos | length %} {# if a photo exists, show it #}
    {% for image in category.photos.limit(1) %}
    {% set params = { width: 300, height: 200 } %}
        &lt;img  src="{{ image.getUrl(params) }}" height="{{ image.getHeight(params) }}" width="{{ image.getWidth(params) }}" alt=""&gt;
    {% endfor %}
  {% else %} {# if no photo exists, show a default image #}
        &lt;img  src="/img/cover-default.jpg" width="300" height="200" alt=""&gt;&lt;/a&gt;
  {% endif %}


{# output all category entries #}   
    &lt;ul class="sermonadditional"&gt;
   {% for entry in catEntries %}
       &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
   {% endfor %}
   &lt;/ul&gt;
{% endfor %}
It wasn't really clear to me if you want to list only those categories that are related to the current entry
or if you want a list of all categories that are assigned to your sermons.

I dont't think the group filter helps a lot in either case and I'd get the catgories like this.

{% set sermonCategories = entry.series %}


In case you don't want them to be ordered by your manual sort order, you need to
get them using a craft.categories ElementCriteriaModel.

{% set sermonCategories = craft.categories.relatedTo(entry).order('title') %}


To get all the categories you'd query for all of your "sermons" entries first.

{% set sermons = craft.entries.section('sermons') %}
{% set sermonCategories = craft.categories.relatedTo(sermons).order('title') %}


The you can start with your loop. I did some small changes, so that only categories with entries related to it will be shown.

{% for category in sermonCategories %}

    {% set relatedEntries = craft.entries.relatedTo(category) %}

    {# Only show category if there are related entries #}
    {% if relatedEntries|length %}

        {% set image = category.photos.first() %}
        {% set params = { width: 300, height: 200 } %}

        {# If a photo exists, show it, otherwise show a placeholder #}
        {% if image %}
            &lt;img  src="{{ image.getUrl(params) }}" height="{{ image.getHeight(params) }}" width="{{ image.getWidth(params) }}" alt=""&gt;
        {% else %}
            &lt;img  src="/img/cover-default.jpg" width="300" height="200" alt=""&gt;
        {% endif %}

        &lt;ul class="sermonadditional"&gt;
            {% for entry in relatedEntries %}
                &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
            {% endfor %}
        &lt;/ul&gt;

    {% endif %}

{% endfor %}