Can sfimageWrp be removed?

Posted by Community Admin on 05-Aug-2018 17:25

Can sfimageWrp be removed?

All Replies

Posted by Community Admin on 01-Mar-2012 00:00

We have noticed when we add an Image content to a Page or PageTemplate it adds an extra div tag (see below)
<div class="sfimageWrp">
Is there a way to override this or not have the div class generated for images?
We tried to remove the sfimageWrp fro the CssClass in the Image advanced properties, but it keeps adding it when the page html is generated.

Posted by Community Admin on 02-Mar-2012 00:00

Hey Mike,

You can change the class to anything you'd like - but as soon as you remove it, it'll default back to 'sfimageWrp'. So unless you want to build your own custom control that doesn't put a <div> tag around an image, you're stuck with a class attribute...

However, one must cheat where one can so have you tried to replace it in the widget with a zero length space? (yes that's an actual character) The screenshot is in Dutch but should give you a clue as to where to locate it...

Jochem.

Posted by Community Admin on 06-Mar-2012 00:00

Hey guys,

There's something else you can do, though I have to admit that's a nice trick, @Jochem :). @Mike, you can create a custom Image widget, which inherits from the default one and in its code -behind simply override two methods - RedredBeginTag and RenderEndTag. This should be enough to remove the div. Take a look at the sample below:

namespace SitefinityWebApp.Controls
    public class ImageWidget: ImageControl
    
        public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
        
            if (!string.IsNullOrEmpty(this.CssClass))
            
 
                writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CssClass);
               
            
        
 
        public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
        
             
        
    

All the best,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Mar-2012 00:00

Jen,
That is exactly what I did and it works.  Thank you.

This thread is closed