Copied to clipboard

Flag this post as spam?

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


  • Robert 5 posts 55 karma points
    May 01, 2014 @ 07:11
    Robert
    0

    How to get the url of an image in partial view macro

    I apologize in advance for the very basic question.... How do you get an image url from a partial view macro?

    I found code to return a URL with inline Razor code, but i couldn't get it to work when I tried to make it into a macro?

     

    Thank you in advance

    Using Umbraco 7 (Very new to everything about CMS and programming)

     

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    May 01, 2014 @ 07:33
    Jan Skovgaard
    0

    Hi Robert and welcome to our :)

    If you're using Umbraco 7.1.1 you should use the new image cropper as described in the documentation here http://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Image-Cropper - Make sure you read it thoroughly then it should be fairly easy :)

    There is also a free video sample about getting images here http://umbraco.com/help-and-support/video-tutorials/umbraco-fundamentals/razor-recipes/gallery/

    Hope this helps - Otherwise let us know.

    /Jan

  • Robert 5 posts 55 karma points
    May 01, 2014 @ 08:52
    Robert
    0

    Jan,

     

    Thank you.  I appreciate the quick reply

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    May 01, 2014 @ 10:10
    Jan Skovgaard
    0

    Hi Robert

    You're welcome - please let us know if it works out for you :)

    /Jan

  • Steve Morgan 1278 posts 4216 karma points c-trib
    May 01, 2014 @ 11:09
    Steve Morgan
    0

    I found that a lot of the examples are for more complex galleries or multiple images. I had a media picker and just wanted to render a single image. 

    This works: 

    @{

      if(Model.Content.HasValue("myImage")){

            var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue("myImage"));

            <img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")"/>   

        }   

    }

  • Robert 5 posts 55 karma points
    May 03, 2014 @ 00:18
    Robert
    100

    Morgan and Jan,

    Thank you both for your help. 

     

    The code worked... but how can I pass the document type property to the macro? 

     

    Again thank you.

  • Robert 5 posts 55 karma points
    May 03, 2014 @ 00:27
    Robert
    0

    Morgan and Jan,

    Thank you both for your help. 

     

    The code worked... but how can I pass the document type property to the macro? 

     

    Again thank you.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies