0

I have a content type, "Fruit". Using that content type I have created a "Bananas" node. It contains text and link fields that constitute "banana information".

I have media type, "Fruit Image", with a field, "FruitShown". Using that media type I have numerous images of bananas and other fruit.

On my Fruit pages, how can I display automatically in a field all images of bananas (i.e. All images of media type "Fruit Image" that have "bananas" in the "FruitShown" field)?

CONTEXT: I believe I am able to display the banana images in a block using a View with a contextual filter. However I prefer to display the images in a field so that I can wrap the images around a "banana information" CSS float, not just place them in a separate rectangular block (which leaves empty space in my theme).

WHAT I TRIED: I am able to display the banana images in a field by using an entity reference field with an entity reference view reference method, but when adding the "Bananas" node, the images must be selected manually one-by-one. I prefer all of them to display automatically.

1 Answer 1

1

Use the Views Reference Field module

When you've created your view, go to your node strcuture and create a field type using the module above. On node edit you then can select your banana view. This way your view is wrapped inside the same markup just like any other field of your node.

5
  • Thank you but in my experience so far, that has the drawback described in the last paragraph of my question. i.e. The images must be selected manually one-by-one, whereas I want them all to display without having to select them.
    – Nick Hope
    Dec 14, 2017 at 16:36
  • There is no difference between a view in a field, or a view in a block: If you can create a fitting contextual filter (and you stated you can do that), it will work in a field as well as in a block. I've to admit though that I don't understand why you have chosen nodes as data structure for your fruits... I would have chosen taxonomy terms as data structure for fruit types.
    – Hudri
    Dec 14, 2017 at 16:56
  • I found some drawbacks to using taxonomy, as described in my comment of Dec 6 at 14:58 on the 1st answer on this question. However I may still end up doing that. Regarding the question on this page I'm very sorry, I completely overlooked the 1st line of your answer when I read it earlier!! I will try the Views Reference Field module tomorrow. Thank you.
    – Nick Hope
    Dec 14, 2017 at 17:13
  • Your solution, View Reference Field, did work, however I think much more detail would assist others. Should I write another longer answer or accept yours and edit it?
    – Nick Hope
    Dec 16, 2017 at 9:57
  • Just do whatever helps other people the most :-)
    – Hudri
    Dec 18, 2017 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.