[HttpGet]
public JsonResult List()
{
var CaseStudyContentTypeId = Services.ContentTypeService.GetContentType("CaseStudy").Id;
var CaseStudies = Services.ContentService.GetContentOfContentType(CaseStudyContentTypeId).Select(x => new CaseStudy {
BannerImage = Umbraco.Content(x.Id).GetPropertyValue("bannerimage"),
Url = Umbraco.Content(x.Id).Url.ToString(),
SectorName = Umbraco.Content(x.GetValue("selectSector")).Name, //x.GetValue("selectSector").ToString(),
BodyTextHeading = x.GetValue("bodyTextHeading").ToString(),
BannerHeading = x.GetValue("bannerheading").ToString()
});
Model
public class CaseStudy
{
public string SectorName { get; set; }
//public int Id { get; set; }
public string Url { get; set; }
public string BannerHeading { get; set; }
public string BannerImage { get; set; }
public string BodyTextHeading { get; set; }
}
Previously the Banner Image was using a media picker so the images could be accessed through Umbraco.Content, but I have now set them all to use a custom cropper which set them to media types
My question is... how can I now set the BannerImage property to get the relevant media image?
normally I could do something similar to this in a view.
var BannerImage = Model.Content.GetPropertyValue("bannerimage");
var MediaImage = Umbraco.TypedMedia((int)BannerImage);
<source srcset="@MediaImage.GetCropUrl("desktopMax")" />
But I don't have access to the model since am in the controller, and am really stuck, am still new to Umbraco and don't yet fully understand everything, so sorry if things are not clear.
Rendering media type images.
Hi,
Am trying to render a list of media images.
In my view I have:
View
Which is used to call a js file
The js file calls the following controller
Controller
Model
Previously the Banner Image was using a media picker so the images could be accessed through Umbraco.Content, but I have now set them all to use a custom cropper which set them to media types
My question is... how can I now set the BannerImage property to get the relevant media image?
normally I could do something similar to this in a view.
But I don't have access to the model since am in the controller, and am really stuck, am still new to Umbraco and don't yet fully understand everything, so sorry if things are not clear.
Thanks in advance for any help.
is working on a reply...