Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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">
<tr>
<td>

<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>
<div class="ms-WPTitle">
    Background  
</div>
<div class="ms-vb">
    <PublishingWebControls:RichHtmlField id="Background" FieldName="Background" runat="server"/>
</div>
<div class="ms-WPTitle">
Opportunity 
</div>
<div class="ms-vb">
    <PublishingWebControls:RichHtmlField id="Opportunity" FieldName="Opportunity" runat="server"/>
</div>
<div class="ms-WPTitle">
Solution
</div>
<div class="ms-vb">
    <PublishingWebControls:RichHtmlField id="Solution" FieldName="Solution" runat="server"/>
</div>
    <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">
        </PublishingWebControls:SummaryLinkFieldControl>    
    </div>
</td>
<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"/>
</div>

</td>
</tr>
<script language="javascript">if(typeof(MSOLayout_MakeInvisibleIfEmpty) == "function") {MSOLayout_MakeInvisibleIfEmpty();}</script>
</table>
share|improve this question

1 Answer 1

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.

$("#RollupImage").has("img").removeClass("ss-float-right").addClass("ss-float-left"); 
share|improve this answer

Your Answer

 
discard

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.