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

    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

    Hi Linus,

    Have a look at the last post in this thread:

    It explains in detail how to get to the crop.

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

    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

    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;
            if (crops != null |crops.GetType().ToString(!= "System.String")
               <img src="@crops.Find("@name", "bloggnyhet").url" alt="@image.Name" />
            <p>@item.namn @item.CreateDate.ToString("dd MMMM, yyyy")</p>
  • Sebastiaan Janssen 5017 posts 15332 karma points MVP admin hq
    Nov 17, 2011 @ 20:15
    Sebastiaan Janssen

    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.

Please Sign in or register to post replies

Write your reply to: