Copied to clipboard

Flag this post as spam?

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


  • Little North 9 posts 75 karma points
    Nov 10, 2011 @ 12:31
    Little North
    0

    Getting imagecrop in razor

    Hi im sorry if this is a stupid question but im trying to dispay my cropped image in razor

    I can see the image in media/id/cup1_bild.jpg
    "bild" is the name of the crop

    But when I try to display my image in a loop I get nothing:

    <img src="@item.imageCrop.Find("@name", "bild").url" />

    What am I missing?

  • Carsten Fallesen 35 posts 154 karma points
    Nov 10, 2011 @ 17:46
    Carsten Fallesen
    0

    Hi Linus,

    Have a look at the last post in this thread:

    http://our.umbraco.org/forum/developers/razor/25264-Finding-Image-Crops-using-Razor

    It explains in detail how to get to the crop.

  • Little North 9 posts 75 karma points
    Nov 10, 2011 @ 19:08
    Little North
    0

    Im not sure if it matters but im not using the imagecropper in the media section just a file upload in my documenttype. 

    So this:

    var image Model.MediaById(item.bild);   

    Gives this:

    Error loading Razor Script NewsShowAll.cshtml
    Cannot get MediaById without an id

    How do I get the mediaId for my image?


  • Little North 9 posts 75 karma points
    Nov 11, 2011 @ 02:33
    Little North
    0

    here is the hole thing

    @foreach(dynamic item in pagesToList.Skip(currentPage*itemsPerPage).Take(itemsPerPage))
    {
            var newsCopy item.text;
            newsCopy Library.StripHtml(newsCopy);
            newsCopy Library.Truncate(newsCopy150true);
            
            var image Model.MediaById(item.bild);    
            var crops image.imageCropper.crops;
    <h1>@item.Name</h1>        
            if (crops != null |crops.GetType().ToString(!= "System.String")
            
               <img src="@crops.Find("@name", "bloggnyhet").url" alt="@image.Name" />
               
            }
         
            <p>@newsCopy</p>
            <p>@item.namn @item.CreateDate.ToString("dd MMMM, yyyy")</p>
    }
  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Nov 17, 2011 @ 20:15
    Sebastiaan Janssen
    0

    Is this still a problem? If so, make sure that item.bild has a (valid) id in it before you try to get the media item.

  • 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