+ Start a Discussion
jls_74_txjls_74_tx 

IF statement with an image

I have a pageBlockTable and I would like to display an image if certain criteria is met. I have tried every variation I can think of for this formula but the only result I get is showing the text result 'http://www.locatormls.com/staticfiles/misc/{!apt.Star_Image__c}star.png' it doesn't actually show the image. The formula below shows an error - IMAGE can't but used in this formula.

Any suggestions? The full code is below:

{!IF(apt.Star_Image__c > 0,  IMAGE('http://www.locatormls.com/staticfiles/misc/{!apt.Star_Image__c}star.png', "Image"), NULL)}    


<apex:pageBlock >
        <apex:pageBlockTable value="{!HOUDirectory}" id="HOUdir" var="apt" columnClasses="colcenter" headerClass="header" rowClasses="row" columnsWidth="200px,80px,60px,200px,200px,200px,150px">

            <apex:column style="vertical-align:top;text-align:left;font-family:trebuchet ms" headerValue="Complex Name">
                  {!apt.Complex_Name__c}              
            </apex:column>
            <apex:column style="vertical-align: top;font-family:trebuchet ms" headerValue="Phone">
                {!apt.Phone__c}
            </apex:column>
            <apex:column style="vertical-align: top;font-family:trebuchet ms" headerValue="Year Built">
                {!apt.Year_Built__c}
            </apex:column>
            <apex:column style="vertical-align: top;font-family:trebuchet ms" headerValue="Management">
                {!apt.Management_Company__r.Name}
            </apex:column>
            <apex:column style="vertical-align: top;font-family:trebuchet ms" headerValue="Area">
                {!apt.Submarket__r.Name}
            </apex:column>
            <apex:column style="vertical-align: top;font-family:trebuchet ms" headerValue="Commission">
                {!apt.Commission_Type__c}
            </apex:column>
            <apex:column style="vertical-align: top;font-family:trebuchet ms" headerValue="">
               {!IF(apt.Star_Image__c > 0,  IMAGE('http://www.locatormls.com/staticfiles/misc/{!apt.Star_Image__c}star.png', "Image"), NULL)}
            </apex:column>
        </apex:pageBlockTable>
Best Answer chosen by jls_74_tx
ThousifAli99ThousifAli99
Can you try this
<apex:image url ="http://www.locatormls.com/staticfiles/misc/{!apt.Star_Image__c}star.png"  height="40"
rendered="{!IF(apt.Star_Image__c > 0, true, false)}"/>

All Answers

ThousifAli99ThousifAli99
Can you try this
<apex:image url ="http://www.locatormls.com/staticfiles/misc/{!apt.Star_Image__c}star.png"  height="40"
rendered="{!IF(apt.Star_Image__c > 0, true, false)}"/>
This was selected as the best answer
jls_74_txjls_74_tx

That Worked! Thank you.

I almost tried that yesterday, but the default input for rendered was boolean so I didn't realize it would accept an IF statement.