I created 6 nodes containing one image each, and one gallery page to display images from the node references. (I selected the node references for the images I wanted to display when editing this page).

However Galleria always displays the 6 images, even if I select fewer.

I think it is a problem in Galleria, because the problem does not occur if I change the "Manage Display" to use "Rendered Node" instead of "Galleria". When I do this, it shows the only the images from the nodes I have selected.

So it seems that the selection and references work ok, but that Galleria is somehow ignoring the selection. It is like Galleria is querying the field table of all images, rather than the node reference table.

Comments

miro_dietiker’s picture

Do you have revisions enabled?
If so, a wrong/missing join might result in displaying all (ever) referenced nodes, instead of current...

jm1’s picture

I do not have any revisions.

The problem isn't that it is displaying all the 'referenced' image nodes, rather it is displaying all the image nodes including the ones that haven't been 'referenced' anywhere.

I did a test by selecting only one of my six nodes. This node (and only this node) appeared in the mysql table: field_data_field_imgnoderef as you'd expect. When I selected a second node, it also appeared in this table.

So I suspect that Galleria is reading the wrong table - maybe it is reading field_data_field_image instead, where all 6 image nodes are listed.

kroimon’s picture

Yeah, the node_reference support is currently very limited.
It just fetches all images from the referenced field, not just from the specific instance of the node you referenced...

This doesn't make a lot of sense...

jm1’s picture

To improve the node_reference support, would it be an idea to copy the code from the standard image renderer (the one called when setting "Rendered Node" on "Manage Display"), and put it in the Galleria module?

This code seems to obtain the correct list of files, how much effort would it be to do this?

kroimon’s picture

Yeah, we're currently querying the database manually, which isn't a very clean solution.
I'll try to change it so it uses the Field Storage API...

jm1’s picture

Great! I'll be tinkering around with this for the next couple of days, is there something I can help with?

kroimon’s picture

Ok, I know how to do it and it works.
It just needs a little more work to be nice, because I need to edit the display settings form where you select which image field(s) from the referenced nodes should be displayed.

jm1’s picture

Regarding this form, it would be good if you could make it possible to change the order of the images (when using check box selection). I think this was only possible when using texts fields to define the selection.

I'll try it out as soon as you're ready.

kroimon’s picture

I don't think this is possible as the space I have for that form is pretty limited.
It would at least require a table with select boxes for the order (and some jQuery magic to replace them with drag handles) and a lot of internal stuff.

I'm sticking with checkboxes for now. Feel free to provide a patch for the rest later ;-)
Oh and: plain text fields are a no-go...

kroimon’s picture

Title: Selection ignored - all imagenodes displayed » node_reference support: too many image nodes displayed
Status: Active » Needs review

I just pushed commit 116b782:

Issue #1343874 by jm1: node_reference support: too many image nodes displayed

This replaces a long overdue workaround which loaded the images for a node_reference gallery directly from the database instead of using the Field API.
It's now possible to select multiple image/media fields to show when formatting a node_reference field.
At the same time we got rid of the 'galleria_' prefix for the field formatter settings which requires an update.php run to adopt the old settings.

It should be included in the next dev build. Please test it and report any issues here :-)

jm1’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev

I tried it and now no images are displayed (the Galleria box is not loaded on the page).

I tried 7.x-1.x-dev from 2011-Nov-20. I did update.php and cleared the caches.

Just to test that the page was ok, in "Manage Display" I selected "Rendered Node" instead of "Galleria". My images appeared as expected. Changing back to "Galleria", they disappeared.

kroimon’s picture

Did you check the Formatter settings on the 'Manage display' page? You have to select the correct image fields there, otherwise no pictures show up at all...
Maybe I should change that default behavior and use all fields when none is selected.

jm1’s picture

Yes, that was it, I selected the correct image field in 'Manage display' formatter settings, and it worked.

Thanks for this!

kroimon’s picture

Status: Needs review » Fixed

Changed the default behavior to use every image/media field of the referenced nodes if nothing else is configured in the 'Manage display' formatter settings.

I think this issue is fixed now :-)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.