function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mat_tone_84mat_tone_84 

hide images with condition

Hi,

I have a VF page that render as Pdf.

I need to show an image if a custom field has a custom value

 

This code works properly since some days ago but now doesn't work and I didn't any change to code!

 

<img id="id_image"  src="{!if(opportunity.field__c = "a",'/servlet/servlet.FileDownload?file=01520000001OEBG','')}"  height ="{!if(opportunity.field__c = "a",'948','0')}" width = "{!if(opportunity.field__c = "a",'700','0')}" />

 I get this error: 

The image at '' has a dimension set to 0. This can happen when the image is cached and later used with a different CSS style. Add a '?style=YourCssStyle' query parameter to the image URL to prevent caching.

 

I try to substitute 0 with null but I have a small image in the top corner left

 

How can I change the code or Do you know anoter way for my problem ? 

 

thanks

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
    <apex:image
        rendered="{!opportunity.field__c='a'}"
        width="700"
        height="948"
        url="/servlet/servlet.FileDownload?file=01520000001OEBG"/>

If Field__c is "a", then the image is rendered, otherwise it won't be. You don't need to set the other attributes conditionally.

All Answers

sfdcfoxsfdcfox
    <apex:image
        rendered="{!opportunity.field__c='a'}"
        width="700"
        height="948"
        url="/servlet/servlet.FileDownload?file=01520000001OEBG"/>

If Field__c is "a", then the image is rendered, otherwise it won't be. You don't need to set the other attributes conditionally.

This was selected as the best answer
mat_tone_84mat_tone_84

thanks, it works properly!!