Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • seregmir 4 posts 24 karma points
    Mar 04, 2014 @ 10:24
    seregmir
    0

    Loading image from umbraco control

    I am trying to load an image on the webpage that i have uploaded through the media folder onto the umbraco control. On my webpage i am trying to load it with the following code:

            <div class="inhoudWelkom">

                <div id="image">@Umbraco.Field("welkomImage")</div>

            </div>

    all i get in response is a number (1083). Anyone can help me to show the image instead of the number.

  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 04, 2014 @ 10:40
    Fuji Kusaka
    0

    You are actually geting the image Id from the Media Folder. If am not mistaken you are using a media Picker here right? 

     

  • seregmir 4 posts 24 karma points
    Mar 04, 2014 @ 10:43
    seregmir
    0

    Yes I am using the media picker.

  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 04, 2014 @ 10:59
    Fuji Kusaka
    0

    Try this

    @{
    var mediaPicker = Model.welkomImage;
    if(!String.IsNullOrEmpty(mediaPicker)){

    var img = Model.MediaById(mediaPicker);
     <div id="image"><img src="@img.umbracoFile"></div>
    }
  • seregmir 4 posts 24 karma points
    Mar 04, 2014 @ 11:07
    seregmir
    0

    Getting this error now,

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

    Compiler Error Message: CS1061: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'welkomImage' and no extension method 'welkomImage' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)

    Source Error:

     
    Line 15:         <div class="inhoudWelkom">
    Line 16:             @{
    Line 17: var mediaPicker = Model.welkomImage; Line 18: if(!String.IsNullOrEmpty(mediaPicker)){
    Line 19: 
  • seregmir 4 posts 24 karma points
    Mar 04, 2014 @ 11:22
    seregmir
    0

    found the problem, thanks for the code :)

  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 04, 2014 @ 11:24
    Fuji Kusaka
    0

    What version of umbraco are you using  ? 

    @using umbraco.MacroEngines;
    @using umbraco.cms.businesslogic.media;
    @using umbraco.BusinessLogic;
    @inherits umbraco.MacroEngines.DynamicNodeContext 
    @{
            var mediaPicker = Model.welkomImage;
            if(!String.IsNullOrEmpty(mediaPicker)){
                var img = Model.MediaById(mediaPicker);
                 <div class="inhoudWelkom">           
                         <div id="image"><img src="@img.umbracoFile"></div>                
                     </div>
            }
    } 
Please Sign in or register to post replies

Write your reply to:

Draft