问题
I use query layouts with properties and had been using .Url.Absolute in versions previous to 1.7 to get the path to an image.
Is there way to produce the image url and other properties from the new media library in a layout?
Thanks!
回答1:
Go to the Bindings tab under Queries. Under Orchard.MediaLibrary.Models.MediaPartRecord you'll see MediaPath and FileName, that together should get you where you need to be: those properties will then be available for you to add from the layout editor. Ideally, you could bind the MediaUrl property, but I think it being read-only is what prevents it from showing in the possible bindings. That may be worth filing abug, because it would be a lot more convenient a solution.
回答2:
for using {Content.Fields.MyPicture.Url.Absolute}
you must Enable
Url Alternates
from modules features first.
回答3:
There is a Url
token for MediaLibraryPickerField
which is chainable with Url tokens.
Example:
{Content.Fields.MyPicture.Url.Absolute}
来源:https://stackoverflow.com/questions/17888031/how-can-i-display-images-with-projection-layouts-in-orchard-1-7