Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8325585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:29:15+00:00 2026-06-09T00:29:15+00:00

MediaPickerFields still elude me. I’ve defined a new Part in Migrations.cs and added a

  • 0

MediaPickerFields still elude me.

I’ve defined a new Part in Migrations.cs and added a Boolean column and a MediaPickerField to the part as follows:

SchemaBuilder.CreateTable("ImageContentPartRecord", table =>
            table.ContentPartRecord()
            .Column("DisplayImage", DbType.Boolean));

ContentDefinitionManager.AlterPartDefinition("ImageContentPart", builder =>
            builder
                .Attachable()
                .WithField("ImageField", fld =>
                    fld.OfType("MediaPickerField")
                    .WithDisplayName("Image")));

Assuming I have ImageContentPart and ImageContentPartRecord classes, how can I retrieve the data from my MediaPickerField (url, dimensions, alt text, class, etc) in my Driver and in my Part Templates (Edit / Display)?

i.e. – Parts.ImageContent.cshtml (I want to accomplish something like this):

<div>
     <img src="@Model.ImageField.Url" alt="@Model.ImageField.Alt" />
</div>

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:29:16+00:00Added an answer on June 9, 2026 at 12:29 am

    Here is the solution:

    In my Display Driver method, I make sure to pass my ImageContentPart(part) when building the ContentShape:

    return ContentShape("Parts_ImageContent", () =>
                shapeHelper.Parts_ImageContent(
                    Content: part));
    

    Then in my Template View, I leverage the dynamic nature of Orchard’s architecture to consume my MediaPickerField. To do this, you access the .ContentItem property on your part, then leaning on dynamics, chain the part name (.ImageContentPart) and then the field name (.ImageContent) to access the field.

    @{
        // Attempting to access MediaPickerField named 'ImageContent'
        var image = Model.Content.ContentItem.ImageContentPart.ImageContent;
    
        // Leaning on Orchard dynamics to access properties of the field
        var url = image.Url;
    }
    
    <img src="@url" alt="@T(image.AlternateText)" />
    

    Here is an exhaustive list of MediaPickerField properties from \\Orchard.Fields\Views\Fields\MediaPicker.cshtml:

    @* 
        Alternate Text: @Model.ContentField.AlternateText
        Class: @Model.ContentField.Class
        Style: @Model.ContentField.Style
        Alignment: @Model.ContentField.Alignment
        Width: @Model.ContentField.Width
        Height: @Model.ContentField.Height
        Url: @Model.ContentField.Url
    
    
        You can also display an image using this example, and add the attributes you need:
        <img src="@Href(Model.ContentField.Url)" />
    *@
    

    Hopefully, if you stumble upon a similar problem, this will help out!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to import data into Orchard CMS. I have a custom type,
I'm trying to change the layout of the admin page for a type and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.