SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom page layout. Similar to an Article page where an image can be uploaded and displayed in the left side of the text. If there is no image I have an indentation for the text. I have googled and binged and cannot find any good fixes to this problem. Would anyone have any thoughts I was thinking jquery to hide it if it does not find any img tag but when I do that it also hides the ability to add an image when the page is in edit mode. Here is what I currently have.

<table width="100%" border="0">

<div id="RollupImage" style="float:left">
<PublishingWebControls:RichImageField id="ContentQueryImage" FieldName="PublishingRollupImage" AllowHyperLinks="false" runat="server"/>
<PublishingWebControls:RichHtmlField id="Caption" FieldName="PublishingImageCaption"  AllowTextMarkup="false" AllowTables="false" AllowFonts="false" PreviewValueSize="Small" runat="server"/>
<div class="ms-WPTitle">
<div class="ms-vb">
    <PublishingWebControls:RichHtmlField id="Background" FieldName="Background" runat="server"/>
<div class="ms-WPTitle">
<div class="ms-vb">
    <PublishingWebControls:RichHtmlField id="Opportunity" FieldName="Opportunity" runat="server"/>
<div class="ms-WPTitle">
<div class="ms-vb">
    <PublishingWebControls:RichHtmlField id="Solution" FieldName="Solution" runat="server"/>
    <div class="WYNTKHeader ms-WPTitle"></div>
        <div id="WYNTK" class="ms-vb">  
        <PublishingWebControls:SummaryLinkFieldControl FieldName="WhatYouNeedToKnow" runat="server" id="WhatYouNeedToKnow" ItemXslLink="/Style Library/XSL Style Sheets/ItemStyleLinks.xsl" ChromeType="TitleOnly" Title="What You Need to Know">
<td style="padding:5px">&nbsp;</td>
<td valign="top" width="25%">

<div class="CFHeader ms-WPTitle"></div>
<div class="ms-vb" style="font-style:italic" >
    <PublishingWebControls:RichHtmlField id="CustomerFeedback" FieldName="CustomerFeedback" runat="server"/>

<script language="javascript">if(typeof(MSOLayout_MakeInvisibleIfEmpty) == "function") {MSOLayout_MakeInvisibleIfEmpty();}</script>
share|improve this question
up vote 1 down vote accepted

After fighting with multiple ways of doing this I find myself a little dumbfounded that it was as easy as this. I am essentially checking the div id to see if it has any img child elements. If so I change the class.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.