本文整理汇总了C#中umbraco.cms.businesslogic.media.Media.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Media.GetProperty方法的具体用法?C# Media.GetProperty怎么用?C# Media.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.media.Media
的用法示例。
在下文中一共展示了Media.GetProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHtmlForFile
/// <summary>
/// Gets the HTML for file.
/// </summary>
/// <param name="media">The media.</param>
/// <returns></returns>
private string GetHtmlForFile(Media media)
{
// check that its not null
if (media != null)
{
// get the img src
var file = media.GetProperty<string>(Constants.Umbraco.Media.File);
// check that the file has a value
if (!string.IsNullOrEmpty(file))
{
// define the anchor tag
var anchor = "<a href=\"{0}\">{1}</a>";
// format the anchor tag
return string.Format(anchor, file, media.Text);
}
}
// fall-back return an empty string
return string.Empty;
}
示例2: GetHtmlForImage
/// <summary>
/// Gets the HTML for an image tag, using the Media Id.
/// </summary>
/// <param name="media">The media.</param>
/// <returns>Returns a HTML image tag from a Media Id.</returns>
private string GetHtmlForImage(Media media)
{
// check that its not null
if (media != null)
{
// get the img src
var src = media.GetProperty<string>(Constants.Umbraco.Media.File);
// check that the img src has a value
if (!string.IsNullOrEmpty(src))
{
// define the img tag
var img = "<img src=\"{0}\" alt=\"{1}\" height=\"{2}\" width=\"{3}\" />";
// get the height
var height = media.GetProperty<int>(Constants.Umbraco.Media.Height);
if (height <= 0)
{
height = (int)this.Height.Value;
}
// get the width
var width = media.GetProperty<int>(Constants.Umbraco.Media.Width);
if (width <= 0)
{
width = (int)this.Width.Value;
}
// if the default dimensions are less then zero...
if (height <= 0 && width <= 0)
{
// default the height & width to 100px;
height = 100;
width = 100;
}
// format the img tag
return string.Format(img, src, media.Text, height, width);
}
}
// fall-back return an empty string
return string.Empty;
}