2

I would like to display an image attachment on my visualforce page (via standard controllers).

What I would like to add is a render statement to only show this the attachment exists? Right now the page shows an error if there isnt any images attached to the record.

Apex

<apex:image url="{!URLFOR($Action.Attachment.Download, News__c.Attachments[0].Id)}" styleClass="img-responsive"></apex:image>

1 Answer 1

1

Use the rendered attribute.

<apex:image url="{!URLFOR($Action.Attachment.Download, News__c.Attachments[0].Id)}" styleClass="img-responsive" rendered="{!News__c.Attachments.Size>0}"!></apex:image>
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .