MediaObject
in namespace DotVVM.Framework.Controls.Bootstrap4
Renders a clickable image with description inside Bootstrap Media List.
Usage & Scenarios
Renders Bootstrap 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 | |
---|---|---|---|---|---|
AlternateText | String | Gets or sets the alternate text of the image. |
attribute
static value
bindable
|
null | |
Attributes | Dictionary<String,Object> |
attribute
static value
|
null | ||
ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
ContentTemplate | ITemplate | Gets or sets the content inside the Media object. Use this property if you don't want the default template. |
inner element
static value
|
null | |
DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. |
attribute
bindable
|
null | |
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
static value
bindable
|
null | |
Enabled | Boolean | Gets or sets whether this image link is enabled. |
attribute
static value
bindable
|
True | |
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
static value
bindable
|
null | |
Height | String | Gets or sets the height of the image. |
attribute
static value
bindable
|
null | |
ID | String | Gets or sets the unique control ID. |
attribute
static value
bindable
|
null | |
ImageType | ImageType | Gets or sets the type of the image - e.g. rounded, circle, responsive etc. |
attribute
static value
|
Default | |
ImageUrl | String | Gets or sets the URL of the image. |
attribute
static value
bindable
|
null | |
IncludeInPage | Boolean | Gets or sets whether the control is included in the DOM of the page. |
attribute
bindable
|
True | |
InnerText | String | Gets or sets the inner text of the HTML element. |
attribute
static value
bindable
|
null | |
MediaTemplate | ITemplate | Gets or sets a template for a custom content to be used instead of the image. |
inner element
static value
|
null | |
NavigateUrl | String | Gets or sets the URL of the hyperlink. |
attribute
static value
bindable
|
null | |
NestedItems | List<MediaObject> | Gets or sets nested Media objects. |
inner element
static value
|
null | |
Position | MediaHorizontalPosition | Gets or sets whether the image is on the left or the right side. |
attribute
static value
|
Left | |
RouteName | String | Gets or sets the name of the route which will be used to generate the URL. |
attribute
static value
|
null | |
UrlSuffix | String | Gets or sets the suffix that will be appended to the generated URL. |
attribute
static value
bindable
|
null | |
VerticalAlignment | VerticalAlignment | Gets or sets the vertical alignment of the image. |
attribute
static value
|
None | |
Visible | Boolean | Gets or sets whether the control is visible. |
attribute
bindable
|
True | |
Width | String | Gets or sets the width of the image. |
attribute
static value
bindable
|
null |
Events
Name | Type | Description | |
---|---|---|---|
Click | Command | Gets or sets the command that will be triggered when the image is clicked. |