This project is read-only.

Media Library Picker Field query

Topics: General
Jul 16, 2013 at 11: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?


(PS - looking forward to the 1.7 release, looking good :) )
Jul 16, 2013 at 6: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 10:46 AM
Ok thanks, I will take a look.
Aug 11, 2013 at 7: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 10:27 AM
Edited Aug 14, 2013 at 10: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.


EDIT: i just found that:

so i guess it will be working in 1.7.1? :)
Sep 27, 2013 at 5: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 1:21 PM
I am also having the same issue. In the past I did
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 8:26 PM
Enruse you use Orchard 1.7.1
In your view, you then can use this:
Oct 1, 2013 at 9: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.
Oct 2, 2013 at 2: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.