I have an Entry Type with a field called Gallery with a handle of gallery. Here are two examples of how I can access the Gallery field in a template:
{% set images = entry.gallery %}
{% set images = craft.assets({
source: 'images',
relatedTo: {sourceElement: entry.id, field: 'gallery'},
order: 'sortOrder'
}) %}
The problem:
The first method works with Live Preview, the second does not. This wouldn't be an issue, but it's my understanding that we have to use the second method to eager load elements. So if I wanted to eager load a relationship on my gallery images, then Live Preview wouldn't work.
Is anyone else running into this issue? Is it a known bug or a misunderstanding of the implementation?
Thanks
Edit
To clarify via Brad's question, the following is the only thing in my template. This does NOT work with Live Preview:
{% set images = craft.assets({
relatedTo: {sourceElement: entry.id, field: 'gallery'}
}) %}
{% for image in images %}
{{ image.url }}<br />
{% endfor %}
The entry variable is populated defining the Entry Template in the section settings.
Using the following WORKS with live preview:
{% set images = entry.gallery %}
{% for image in images %}
{{ image.url }}<br />
{% endfor %}
entryin the first example. – Brad Bell Jul 01 '16 at 22:13galleryfield, created an entry, added two images to the field, and in the template fetched them both ways, and looped through the urls. In live preview, both lists of images initially show both urls. But when I add or remove or reorder images from the field, only the list set withentry.gallerygets updated in live preview.Confirming that I see a difference too.
– Marion Newlevant Jul 04 '16 at 20:34