AI OnAI Off
Here are a couple of approaches at rendering image URLs which you could use for inspiration:
<asp:Image runat="server" ImageUrl="<%=UrlResolver.Current.GetUrl(CurrentPage.ImagePropertyName)%>"/>
<img src="<%=UrlResolver.Current.GetUrl(CurrentPage.ImagePropertyName)"/>
Just render the appropriate attributes by accessesing the properties of the block in the same way as above.
Urrgh, web forms...
Thanks,
Is there a way to access the ImageMedia attributes (AltText and TitleText) by using the ContentReference?
I have tried to add the page property as below,
[CultureSpecific]
[Required]
[UIHint(UIHint.Image)]
[Display(
Name = "Image",
GroupName = SystemTabNames.Content,
Order = 40)]
public virtual ImageMedia Image { get; set; }
But it throws an error in runtime saying "Type 'ImageMedia' could not be mapped to a PropertyDefinitionType"
Ok gotcha !,
I have used
var img = contentLoader.Get<ImageMedia>(CurrentBlock.Image);
to get the ImageMedia object from the codebehind. Now I could access the inner attributes from it.
Thanks :)
Here is my ImageMedia.cs file which inherits ImageData
And it is displaying in the editmode as follows,
I have made a ContentReference as like below in the block
However, when I used to show that in the view (Web Forms), it is just displaying the image. Without having any Alt text or Title.
I have accessed that image like below in the view,
When it is rendered in view, the code looks like this,
How can I show the AltText and the TitleText as "alt" and "title" in the finally rendered view?
Thanks in advance :)
I am having,
EPiServer.CMS.Core version=11.11.0
EPiServer.CMS.UI version=11.14.0
EPiServer.CMS.UI.Core version=11.14.0