Created
January 31, 2012 11:05
-
-
Save warrenbuckley/1709929 to your computer and use it in GitHub Desktop.
Umbraco V5 Example - Media Upload Property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits PartialViewMacroPage | |
@using Umbraco.Cms.Web | |
@using Umbraco.Cms.Web.Macros | |
@using Umbraco.Framework | |
@{ | |
//Output an image from an upload property on current doctype | |
//Property alias of upload field | |
var uploadPropAlias = String.IsNullOrEmpty(Model.MacroParameters.uploadPropAlias) ? "myUploadPropertyAlias" : Model.MacroParameters.uploadPropAlias; | |
//Check if Value is not an empty HiveId | |
if (DynamicModel[uploadPropAlias].Value != HiveId.Empty.ToString()) | |
{ | |
//Get the image URL | |
//The HiveID of the currentpage | |
//Then the string property alias of the upload property | |
var imageURL = Umbraco.GetMediaUrl(DynamicModel.Id, uploadPropAlias); | |
<img src="@imageURL" alt="@DynamicModel.Name" /> | |
} | |
else | |
{ | |
<p>No Media present</p> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment