For many of Custom Types created, we have a Query for them. These queries are being used by Projection Widgets (Within Zones).
Few of the custom types have Media Picker field.The Layout type I used for my Queries is the Shape type as seen below:
=>>> Layout:
. I have followed the steps from here.. I specified the name of the shape as : UpcomingHighlightsImages as seen below:
and then included the view: UpcomingHighlightsImages.cshtml in my Themes/MyFirstTheme/Views folder.
Everything works fine upto here.
In the View, problem is that there is NO way to read the Image Metadata such as altText, altHeight etc... Neither there seems to be a way to set these metadata firstly in Orchard itself.
@using Orchard.ContentManagement
@using Orchard.Core.Title.Models
@using Orchard.Fields.Fields
@using Orchard.Taxonomies.Fields
@using Orchard.Core.Common.Fields;
@using Orchard.MediaLibrary.Fields;
@{
var HighlightItems = ((IEnumerable<ContentItem>)Model.ContentItems).ToList();
}
@foreach (var item in HighlightItems)
{
String LinkUrl = ((TextField)item.Parts.SelectMany(x => x.Fields).Single(x => x.Name == "LinkURL")).Value;
String ImagePath = ((MediaLibraryPickerField)item.Parts.SelectMany(x => x.Fields).Single(x => x.Name == "MainImage")).MediaParts.First().MediaUrl;
<div>
<a target="_blank" href="@LinkUrl">
<img src="@ImagePath" />
</a>
</div>
}
So, as seen in above code and the tag, I need:
- Set the altText, altHeight property of Image in ORchard CMS
- Read these in my view , the way I read
LinkUrlandImagePath
Please guide me !


See how you got the first media part in that
ImagePathexpression? Well, then you can take that part and getTitle,Caption,AlternateText, etc. from it. You can alsoAs<ImagePart>()it and get itsWidthandHeight.