Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
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.
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.cshtmlCannot get MediaById without an id
How do I get the mediaId for my image?
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(newsCopy, 150, true); 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>}
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.
is working on a reply...
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.
Continue discussion
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:
What am I missing?
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.
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:
Gives this:
Error loading Razor Script NewsShowAll.cshtml
Cannot get MediaById without an id
How do I get the mediaId for my image?
here is the hole thing
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.
is working on a reply...
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.