MOSS PublishingWebControls:RichImageField problems
May 9, 2007 – 3:34 amThe CMS features of MOSS are cool, but IMO they clearly were not been thought a very good quality check.
Almost every single SharePoint control render itself in quirks mode, and usually outputs content even if they have nothing in it.
PublishingWebControls:RichImageField is an example. If you don’t put any image in it, it stills render some divs, spans and HTML nbsp spaces. And those nbsp spaces usually creates 2px gaps on IE and other browsers.
How to fix it then?
I created a small javascript using the same approach that the BlankWebMastepage page uses. Just warp your RichImageField around a div like this:
<div id="_fixRichImageField" name="_fixRichImageField">
<PublishingWebControls:RichImageField FieldName="Banner" runat="server"></PublishingWebControls:RichImageField></div>
and put this javascript at the end of your masterpage:
<script language="javascript" type="text/javascript">
function fixRichImageField()
{
var allElements=document.getElementsByName("_fixRichImageField");
for (var curElement = 0; curElement < allElements.length; curElement++)
{
if(allElements[curElement].innerHTML.toLowerCase().indexOf("</span> ") != -1)
{
allElements[curElement].innerHTML = allElements[curElement].innerHTML.toLowerCase().replace('</span> ', '</span>');
}
}
}
if(typeof(fixRichImageField) == "function") {fixRichImageField();}
</script>
4 Responses to “MOSS PublishingWebControls:RichImageField problems”
Hi Guilherme,
I came across your script to manage the issues in the RichHtmlField… I tried to use your script at the end of the master page but unfortunately it didn’t work. I put alert in the code to see that if the change takes place or not. It appeared that when I put alert on the replaced innerHTML, it showed changed innerHTML in dialog box, but on the rendered page the HTML didn’t change. It was the same and not . I also tried to place the script at the top of the page under the tag but it also did not work out. Can you please help me out of this?
By Hardik on Sep 18, 2008
oops… consider RichImageField rather than RichHtmlField… i’m so frustrated
By Hardik on Sep 18, 2008
For other people reference:
http://blogs.msdn.com/ecm/archive/2007/02/21/using-field-value-controls-and-edit-mode-panels-to-tweak-your-page-rendering.aspx
By Guilherme Magalhães on Sep 19, 2008
This excellent idea is necessary just by the way
I think, that you are mistaken. I can defend the position. Write to me in PM, we will communicate.
It is very a pity to me, I can help nothing to you. But it is assured, that you will find the correct decision.
It is remarkable, and alternative?
I think, that you are mistaken. I suggest it to discuss. Write to me in PM, we will talk.
By epoct.ru on Feb 21, 2010