Setup
Right now I've added a "caption" field to my "Image" file types. On my "blog" content type I've added a media selector "field_image" so that users can upload images with captions.
Desired outcome
I'd like to output those images and captions using views. So I create a view of "Type: Content". I add the "field_image" field and get the images displaying correctly. Then I want to add the "caption" field, so I have to add the "File Usage: File" relationship to the view.
Problem
As soon as I add the "File Usage: File" relationship, duplicates start appearing in the view.
Thoughts on how this might be possible? I've also tried creating a view of "Type: File" but I'm unable to successfully add the "Content: NID" argument so that I can restrict it to the page currently being viewed.
Comments
Comment #1
Dave ReidDon't use the File usage relationship. Use the Content: Image (field_image:fid) relationship (make it required so that it won't process nodes that don't have any image data) and then add the caption field using that relationship.
Comment #2
bryancasler CreditAttribution: bryancasler commentedHi Dave, that relationship doesn't seem to be an option (screenshot). I did figure out a way to get this working, with some limitations, but you were faster than I could follow up :)
Instead of adding the image field (screenshot) add the "File Usage: File" relationship and then add "File: rendered file" field (screenshot). Then add the contextual filter "Content: NID" with the option "Provide default value" and "Content ID from URL".
I know this is a horrible way to go about doing this, but I go on vacation tomorrow and I just need it to work well enough for the next week while I'm gone.
I'm using the unstable3 release, should I switch to the dev release and try again?
Comment #3
Dave ReidVersion of file_entity should not matter. I'm not sure why you don't have the correct relationship available to select from - maybe you need to ensure you're running the latest version of Views? Is your image field the 'Quick image upload' field?
Comment #4
bryancasler CreditAttribution: bryancasler commentedThanks for the quick respond Dave, I've been running...
Views from 2/8 "version = "7.x-3.1+56-dev"
File entity 1/12 "version = "7.x-2.0-unstable3"
To see if outdated modules were the cause I just updated it to...
Views from 2/20 "7.x-3.2"
File entity from 2/21 "7.x-2.0-unstable3+17-dev"
Quick image upload is not the correct field. The one I'm looking for is called "Image" and is "field_image". Unfortunately after updating "Content: Image (field_image:fid) relationship" is still not available.
Comment #5
bryancasler CreditAttribution: bryancasler commentedDave, do you think this might be the problem? The field in question is a "Multimedia Asset" (screenshot).
Comment #6
Dave ReidThat would definitely be the problem.
Comment #7
Dave ReidI have this tracked down to a bug in the media field Views integration. I'm fixing it shortly.
Comment #8
Dave ReidI've tested and fixed this for 7.x-2.x and 7.x-1.x. A new dev release for testing should be available in 12 hours or less.
http://drupalcode.org/project/media.git/commit/8a189d2
http://drupalcode.org/project/media.git/commit/4e33b20
Comment #9
bryancasler CreditAttribution: bryancasler commentedThat looks to have completely fixed it. Thanks Dave!
Comment #10.0
(not verified) CreditAttribution: commentedcc