MediaObject

in namespace DotVVM.Framework.Controls.Bootstrap4

Renders a clickable image with description inside Bootstrap Media List.

Usage & Scenarios

Renders Bootstrap Media Object.

https://getbootstrap.com/docs/4.3/components/media-object/

Sample 1: Basic MediaObject

The MediaObject control has the HeaderText and Description properties which specify the header text and description of the media object.

The ImageUrl and AlternateText property sets the URL and the alt text of the image.

<bs:MediaObject ImageUrl="~/Images/person.png" 
                HeaderText="Basic Image" 
                Description="Simple Description" />

Sample 2: Media Object Templates

The MediaObject control supports templating for media content and body.

You can use the MediaTemplate property to define any content for the media section.

Also, instead of HeaderText and Description, you can use the ContentTemplate to specify your own content.

<bs:MediaObject>
  <MediaTemplate>
    <iframe width="300" height="180" src="https://www.youtube.com/embed/fJ9rUzIMcZQ" frameborder="0" allowfullscreen=""></iframe>
  </MediaTemplate>
  <ContentTemplate>
    <h1>Header</h1>
    <p>Description defined in content template.</p>
  </ContentTemplate>
</bs:MediaObject>

Sample 3: Nested MediaObjects

You can nest MediaObject controls to create hierarchies.

Use ContentTemplate to provide the title and description of the media, and use MediaObject control inside this template.

<bs:MediaList>

    <bs:MediaObject ImageUrl="~/Images/person.png" VerticalAlignment="Start" AlternateText="TEST">
        <ContentTemplate>
            <h4>Media object in list</h4>
            <p>Description in template</p>

            <bs:MediaObject ImageUrl="~/Images/person.png" VerticalAlignment="Start" AlternateText="TEST">
                <ContentTemplate>
                    <h4>Child</h4>
                    <p>Description of a child</p>

                    <bs:MediaObject HeaderText="Nested Media Object" Description="Simple description" VerticalAlignment="Start">
                        <MediaTemplate>
                            <iframe width="300" height="180" src="https://www.youtube.com/embed/fJ9rUzIMcZQ" frameborder="0" allowfullscreen=""></iframe>
                        </MediaTemplate>
                    </bs:MediaObject>

                </ContentTemplate>
            </bs:MediaObject>

        </ContentTemplate>
    </bs:MediaObject>

    <bs:MediaObject ImageUrl="~/Images/person.png" VerticalAlignment="Start" AlternateText="TEST" />

</bs:MediaList>

Sample 4: MediaObject Alignment

The Position property specifies whether the image is on the left or on the right side.

You can use the VerticalAlignment property to specify the vertical alignment of the image within the row.

<bs:MediaObject ImageUrl="~/Images/person.png" 
                HeaderText="Basic Image" 
                Description="Simple Description"
                VerticalAlignment="End"
                Position="Right" />

Properties

Name Type Description Notes Default Value
property icon AlternateText String Gets or sets the alternate text of the image.
attribute
inner element
static value
bindable
default
null
property icon ContentTemplate ITemplate Gets or sets the content inside the Media object. Use this property if you don't want the default template.
attribute
inner element
static value
bindable
default
null
property icon Description String Gets or sets the description text in the default content template. Do not use this property in combination with the ContentTemplate property.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Gets or sets whether this image link is enabled.
attribute
inner element
static value
bindable
default
True
property icon HeaderText String Gets or sets the header text in the default content template. Do not use this property in combination with the ContentTemplate property.
attribute
inner element
static value
bindable
default
null
property icon Height String Gets or sets the height of the image.
attribute
inner element
static value
bindable
default
null
property icon ImageType ImageType Gets or sets the type of the image - e.g. rounded, circle, responsive etc.
attribute
inner element
static value
bindable
default
Default
property icon ImageUrl String Gets or sets the URL of the image.
attribute
inner element
static value
bindable
default
null
property icon MediaTemplate ITemplate Gets or sets a template for a custom content to be used instead of the image.
attribute
inner element
static value
bindable
default
null
property icon NavigateUrl String Gets or sets the URL of the hyperlink.
attribute
inner element
static value
bindable
default
null
property icon NestedItems List<MediaObject> Gets or sets nested Media objects.
attribute
inner element
static value
bindable
default
null
property icon Position MediaHorizontalPosition Gets or sets whether the image is on the left or the right side.
attribute
inner element
static value
bindable
default
Left
property icon RouteName String Gets or sets the name of the route which will be used to generate the URL.
attribute
inner element
static value
bindable
default
null
property icon UrlSuffix String Gets or sets the suffix that will be appended to the generated URL.
attribute
inner element
static value
bindable
default
null
property icon VerticalAlignment VerticalAlignment Gets or sets the vertical alignment of the image.
attribute
inner element
static value
bindable
default
None
property icon Width String Gets or sets the width of the image.
attribute
inner element
static value
bindable
default
null

Events

Name Type Description
event icon Click Command Gets or sets the command that will be triggered when the image is clicked.

HTML produced by the control