You can create you own class inheriting from the Sitecore.Web.UI.WebControls.Image
and override it like this:
namespace My.Assembly.Namespace
{
public class MyImage : Sitecore.Web.UI.WebControls.Image
{
public virtual string RelAttribute { get; set; }
protected override void PopulateParameters(Sitecore.Collections.SafeDictionary<string> parameters)
{
base.PopulateParameters(parameters);
if (!String.IsNullOrEmpty(RelAttribute))
{
parameters.Add("rel", RelAttribute);
}
}
}
}
And then register the namespace and use the MyImage
class:
<%@ Register tagPrefix="my" namespace="My.Assembly.Namespace" assembly="My.Assembly" %>
<my:MyImage runat="server" RelAttribute="reltest" Field="logo"/>
You can use all the standard attributes from sc:Image
on the my:MyImage
as well.
The code will generate img
tag with rel <img rel="reltest" src="logo.jpg" ... />
.
You can easily extend the code above to support ControlType
attribute as well.