AI OnAI Off
Got this working with Template Coordinator - or IViewTemplateModelRegistrator, but don't think that it is the correct and most straight forward way.
For those who would be interested in this - added a registration for content of type ImageData and passed the data to a view like:
viewTemplateModelRegistrator.Add(typeof(ImageData), new TemplateModel
{
Name = "Image",
Inherit = true,
AvailableWithoutTag = true,
Path = DisplayTemplatesPath("Image.cshtml")
});
Used the ImageData.Content link to extract the url etc..
Any other way of processing this would be appreciated.
Thank you,
Seems a valid solution although an alternate suggestion would be to use an PartialContentComponent, example from Alloy
/// <summary>
/// Controller for the image file.
/// </summary>
public class ImageFileViewComponent : PartialContentComponent<ImageFile>
{
private readonly UrlResolver _urlResolver;
public ImageFileViewComponent(UrlResolver urlResolver)
{
_urlResolver = urlResolver;
}
/// <summary>
/// The index action for the image file. Creates the view model and renders the view.
/// </summary>
/// <param name="currentContent">The current image file.</param>
protected override IViewComponentResult InvokeComponent(ImageFile currentContent)
{
var model = new ImageViewModel
{
Url = _urlResolver.GetUrl(currentContent.ContentLink),
Name = currentContent.Name,
Copyright = currentContent.Copyright
};
return View(model);
}
Hi,
Not sure how to map the default view for an image that has been added to a Content Area. Pre 12 version the default view was possible to be added under ~/Views/Shared/DisplayTemplates/Image.cshtml.
Trying my luck currently with Template Coordinator with no luck so far. Any hints and ideas would be appreciated.
Thanks,