Answers.Body: <p>After using the above and re-reading the docs I got this to work.</p>
  
  <pre><code>  {% set relatedGallery = entry.associatedGallery.first() %}
    {% if relatedGallery %}
      {% for matrixBlock in relatedGallery.albumImages %}
        {% set asset = matrixBlock.imageFile.first() %}
          {% if asset %}
            &lt;a href="{{ asset.getUrl() }}"&gt;&lt;img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"&gt;&lt;/a&gt;
          {% endif %}
      {% endfor %}    
    {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-21T03:01:35.667Z
Answers.LastActivityDate: 2016-08-21T03:01:35.667Z
Answers.UserDisplayName: Phil
Answers.Body: <p>Relationship field is defined like:</p>
  
  <pre><code>{% for relatedItem in entry.relatedItemField %}
    {{ relatedItem.someField }} {{ relatedItem.someOtherField }}    
  {% endfor %}
  </code></pre>
  
  <p>So maybe:</p>
  
  <pre><code>{% if entry.associatedGallery | length %}
      {% for theGallery in entry.associatedGallery %}
          {% for matrixBlock in theGallery.albumImages %}
              {% if matrixBlock.imageFile | length %}
                  {% for asset in matrixBlock.imageFile.first() %}
                      &lt;a href="{{ asset.getUrl() }}"&gt;&lt;img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"&gt;&lt;/a&gt;
                  {% endfor %}
              {% endif %}
          {% endfor %}
      {% endfor %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-21T03:00:11.017Z
Answers.Text: That seems to output a whole lot of info as the asset things like id, publish date and a whole bunch else that doesn't make sense to me but it did get me thinking and rereading the documentation on entry fields specifically. I think it was the .first() I was missing since I have it only set to be one related entry. I think your example might be missing a step where each related entry is defined. Not sure I will have to try a multiple relations example later.
Answers.UserDisplayName: Phil
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-20T21:46:40.190Z
Answers.LastActivityDate: 2016-08-20T21:46:40.190Z
Answers.UserDisplayName: AbbeyDesign
Body: <p>I have a section that is a single type. On this page there is a relation ship ('entries') field where the user can select a related photo gallery. Photo gallery is its own section with a matrix field on it that contains image files and image names. How when I am displaying the single page pull in the matrix field to display an image gallery. This is what I have tried but not with much luck.</p>
  
  <p>I have tried </p>
  
  <pre><code>  {% if entry.associatedGallery is not null %}
      {% set theGallery = craft.entries.section('bb').relatedTo(entry.associatedGallery) %}
        &lt;div class="galleria associated-gallery"&gt;
          {% for matrixBlock in theGallery.albumImages %}
            {% set asset = matrixBlock.imageFile.first() %}
              {% if asset %}
                &lt;a href="{{ asset.getUrl() }}"&gt;&lt;img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"&gt;&lt;/a&gt;
              {% endif %}
          {% endfor %}
        &lt;/div&gt;
      {% else %}
        &lt;h1&gt; Apparently its null&lt;/h1&gt;  
    {% endif %}
  </code></pre>
  
  <p>and </p>
  
  <pre><code>  {% if entry.associatedGallery is not null %}
      {% set theGallery = entry.associatedGallery %}
        &lt;div class="galleria associated-gallery"&gt;
          {% for matrixBlock in theGallery.albumImages %}
            {% set asset = matrixBlock.imageFile.first() %}
              {% if asset %}
                &lt;a href="{{ asset.getUrl() }}"&gt;&lt;img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"&gt;&lt;/a&gt;
              {% endif %}
          {% endfor %}
        &lt;/div&gt;
      {% else %}
        &lt;h1&gt; Apparently its null&lt;/h1&gt;  
    {% endif %}
  </code></pre>
  
  <p>I think I am missing something fundamental about how relationships are defined.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-20T21:34:04.227Z
Comments.Text: Are you pulling just the first image of the related gallery? Or do you want to show all the images of the related gallery?
Comments.UserDisplayName: AbbeyDesign
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-21T02:38:39.860Z
Comments.Text: Looking to pull all images in a gallery. The middle part of that code from 'for matrixBlock in.... is pretty much the same as I use on a gallery entry page. It just uses .first() because each block only contains one image and one title.
Comments.UserDisplayName: Phil
Tags: <matrix><relations>
Title: Displaying images from a matrix field from a related field
ThreadText: # Displaying images from a matrix field from a related field
  
  (Asked by: username_0 on 2016-08-20)
  
  I have a section that is a single type. On this page there is a relation ship ('entries') field where the user can select a related photo gallery. Photo gallery is its own section with a matrix field on it that contains image files and image names. How when I am displaying the single page pull in the matrix field to display an image gallery. This is what I have tried but not with much luck.
  
  I have tried
  
  ```
    {% if entry.associatedGallery is not null %}
      {% set theGallery = craft.entries.section('bb').relatedTo(entry.associatedGallery) %}
        <div class="galleria associated-gallery">
          {% for matrixBlock in theGallery.albumImages %}
            {% set asset = matrixBlock.imageFile.first() %}
              {% if asset %}
                <a href="{{ asset.getUrl() }}"><img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"></a>
              {% endif %}
          {% endfor %}
        </div>
      {% else %}
        <h1> Apparently its null</h1>  
    {% endif %}
  
  ```
  
  and
  
  ```
    {% if entry.associatedGallery is not null %}
      {% set theGallery = entry.associatedGallery %}
        <div class="galleria associated-gallery">
          {% for matrixBlock in theGallery.albumImages %}
            {% set asset = matrixBlock.imageFile.first() %}
              {% if asset %}
                <a href="{{ asset.getUrl() }}"><img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"></a>
              {% endif %}
          {% endfor %}
        </div>
      {% else %}
        <h1> Apparently its null</h1>  
    {% endif %}
  
  ```
  
  I think I am missing something fundamental about how relationships are defined.
  
  **Tags:** matrix, relations
  
  > **Comments:**
  > **username_1**: Are you pulling just the first image of the related gallery? Or do you want to show all the images of the related gallery?  
  > **username_0**: Looking to pull all images in a gallery. The middle part of that code from 'for matrixBlock in.... is pretty much the same as I use on a gallery entry page. It just uses .first() because each block only contains one image and one title.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2016-08-21. Score: 1
  
  After using the above and re-reading the docs I got this to work.
  
  ```
    {% set relatedGallery = entry.associatedGallery.first() %}
    {% if relatedGallery %}
      {% for matrixBlock in relatedGallery.albumImages %}
        {% set asset = matrixBlock.imageFile.first() %}
          {% if asset %}
            <a href="{{ asset.getUrl() }}"><img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"></a>
          {% endif %}
      {% endfor %}    
    {% endif %}
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2016-08-20. Score: 1
  
  Relationship field is defined like:
  
  ```
  {% for relatedItem in entry.relatedItemField %}
    {{ relatedItem.someField }} {{ relatedItem.someOtherField }}    
  {% endfor %}
  
  ```
  
  So maybe:
  
  ```
  {% if entry.associatedGallery | length %}
      {% for theGallery in entry.associatedGallery %}
          {% for matrixBlock in theGallery.albumImages %}
              {% if matrixBlock.imageFile | length %}
                  {% for asset in matrixBlock.imageFile.first() %}
                      <a href="{{ asset.getUrl() }}"><img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"></a>
                  {% endfor %}
              {% endif %}
          {% endfor %}
      {% endfor %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: That seems to output a whole lot of info as the asset things like id, publish date and a whole bunch else that doesn't make sense to me but it did get me thinking and rereading the documentation on entry fields specifically. I think it was the .first() I was missing since I have it only set to be one related entry. I think your example might be missing a step where each related entry is defined. Not sure I will have to try a multiple relations example later.  
  
  ---
  
  