Media Library Picker Field query

Topics: General
Jul 16, 2013 at 10:10 AM
Hi All,

I was looking at the forthcoming 1.7 release last night, especially the Media Library Picker Field. I noticed it stores the IDs for the images in the Ids of the field, which makes sense, but I was wondering on what the best approach would be to then get the url for the images?

When I initial set it up I could of course get the ids on my page, but would i need to get them in the driver and pass the urls as an array model to the view, or am I missing something fancy?

Thanks

(PS - looking forward to the 1.7 release, looking good :) )
Coordinator
Jul 16, 2013 at 5:10 PM
There is a MediaParts proeprty which is a IEnumerable<MediaPart>. Each MediaPart can be rendered independently or you can use .MediaUrl if it is url-based (for instance, OEmbed are not url-based)
Jul 17, 2013 at 9:46 AM
Ok thanks, I will take a look.
Developer
Aug 11, 2013 at 6:45 PM
So say you have a Part with a MediaLibraryPickerField and you want to render this within a Query which pushes Properties out, I cant see how you would do this at the moment, the only thing you get out is an ID?

i.e. {Content.Fields.ProfilePart.Image} just pushes out {1}

Should we not have an option to actually push out the image?
Aug 14, 2013 at 9:27 AM
Edited Aug 14, 2013 at 9:41 AM
I'm asking me the same:
I created a contet type definition with some input fields and a media library picker field.
then i wanted to create a query which renders those input fields as text, which works perfectly, and the image as a <img ..."">. how am i supposed to do that? because with just the Id it's not working i guess.


thanks

EDIT: i just found that:
http://stackoverflow.com/questions/17888031/how-can-i-display-images-with-projection-layouts-in-orchard-1-7

so i guess it will be working in 1.7.1? :)
Sep 27, 2013 at 4:43 PM
Having the same issues, the link here is similar but still does not provide a solution, anyone got this working yet?
Oct 1, 2013 at 12:21 PM
I am also having the same issue. In the past I did
{Content.Fields.Project.Icon.Url.Absolute}
but now I can't find a way to print out the path to the image. All that is written out is the ID.
Oct 1, 2013 at 7:26 PM
Enruse you use Orchard 1.7.1
In your view, you then can use this:
Model.ContentItems[0].YourContentType.YourImageField.MediaParts[0].MediaUrl
Oct 1, 2013 at 8:42 PM
I'm not using the view. I'm using the Properties display mode in the query layout and attempting to get the image to show through a rewrite. However, I do not have access to the URL path. Any tips? If I don't do a rewrite I get "{15}" which is the ID.
Coordinator
Oct 2, 2013 at 1:45 AM
If you look at the media library picker field tokens, you'll see that they have the same structure, so if you have properly migrated your fields using the upgrade module, your expression should still work. If it still doesn't and you are sure you've migrated, put a breakpoint into the evaluate method of FieldTokens.cs in the media library module and see if it gets hit.