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 all -
I have an old razor code that i have written :
@{
var mediaFolder = Library.MediaById(1058);
if(mediaFolder.Children.Count()>0)
{
foreach(var photo in mediaFolder.Children)
if(photo.IsLast())
@:{image : '@photo.uploadSlider', info: "@photo.addTextForTheImage"}
}
else
@:{image : '@photo.uploadSlider', info: "@photo.addTextForTheImage"},
I really need some help to convert that to new syntax for Umbraco 7 ( Library.MediaById to Umbraco.Media etc..)
Please help me on this - so that on future code I get somethng to referenced on.
Thank You
Sam//
Hi Sam,
I think that you should be good with this code.
@{ var mediaFolder = Umbraco.Media(1058); if(mediaFolder.Children.Any()){ foreach(var photo in mediaFolder.Children{ if(photo.IsLast()){ @:{image : '@photo.uploadSlider', info: "@photo.addTextForTheImage"} }else{ @:{image : '@photo.uploadSlider', info: "@photo.addTextForTheImage"}, } } }}
You can find some documentation here: https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/#Media%28%29
Hope it works for you.
/Dennis
Thanks Dennis but still not working ; (
I have added an image cropper and written this :
var mediaFolder = Umbraco.Media(1058);
if(mediaFolder.Children.Any()){
foreach(var photo in mediaFolder.Children{
if(photo.IsLast()){
@:{image : '@Umbraco.Media(@photo.id).GetCropUrl("uploadHomeSlide", "slideCrop")', info: "@photo.addTextForTheImage"}
else{
@:{image : '@Umbraco.Media(@photo.id).GetCropUrl("uploadHomeSlide", "slideCrop")', info: "@photo.addTextForTheImage"},
I get this error : Error loading Partial View script
Any other clue?
Thks again
/Sam
Okay so you are working with the image cropper. You can find the documentation about the image cropper here: https://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Image-Cropper
Another good resource to learn how the image cropper is working is by seen this episode from uHangout.https://www.youtube.com/watch?v=bQsvGmnYaUU
@{ var mediaFolder = Umbraco.Media(1058); if(mediaFolder.Children.Any()){ foreach(var photo in mediaFolder.Children{ if(photo.IsLast()){ <img src='@photo.GetCropUrl("uploadSlider", "banner")' alt="@photo.addTextForTheImage" /> }else{ <img src='@photo.GetCropUrl("uploadSlider", "banner")' alt="@photo.addTextForTheImage" /> } } }}
Where the banner is the name of the crop.
Hope this can help you furhter, how to use the image cropper.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Convert an old razor code to new umbraco 7 partial view
Hi all -
I have an old razor code that i have written :
@{
var mediaFolder = Library.MediaById(1058);
if(mediaFolder.Children.Count()>0)
{
foreach(var photo in mediaFolder.Children)
{
if(photo.IsLast())
{
@:{image : '@photo.uploadSlider', info: "@photo.addTextForTheImage"}
}
else
{
@:{image : '@photo.uploadSlider', info: "@photo.addTextForTheImage"},
}
}
}
}
I really need some help to convert that to new syntax for Umbraco 7 ( Library.MediaById to Umbraco.Media etc..)
Please help me on this - so that on future code I get somethng to referenced on.
Thank You
Sam//
Hi Sam,
I think that you should be good with this code.
You can find some documentation here: https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/#Media%28%29
Hope it works for you.
/Dennis
Thanks Dennis but still not working ; (
I have added an image cropper and written this :
@{
var mediaFolder = Umbraco.Media(1058);
if(mediaFolder.Children.Any()){
foreach(var photo in mediaFolder.Children{
if(photo.IsLast()){
@:{image : '@Umbraco.Media(@photo.id).GetCropUrl("uploadHomeSlide", "slideCrop")', info: "@photo.addTextForTheImage"}
}
else{
@:{image : '@Umbraco.Media(@photo.id).GetCropUrl("uploadHomeSlide", "slideCrop")', info: "@photo.addTextForTheImage"},
}
}
}
}
I get this error : Error loading Partial View script
Any other clue?
Thks again
/Sam
Hi Sam,
Okay so you are working with the image cropper. You can find the documentation about the image cropper here: https://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Image-Cropper
Another good resource to learn how the image cropper is working is by seen this episode from uHangout.https://www.youtube.com/watch?v=bQsvGmnYaUU
Where the banner is the name of the crop.
Hope this can help you furhter, how to use the image cropper.
/Dennis
is working on a reply...