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
chaitanya Krishna 19chaitanya Krishna 19 

Partner Community

Hi Team,

In Partner Portal.. I attached 4 Images in Notes and attachments to different Account ... and scenario  is images should display dynamically basing on the logged in account... i am not able to refer on Visualforce Page.... Can yu please help me on the code...Help me how to refer in VF pages...

Thanks In advance
Best Answer chosen by chaitanya Krishna 19
bk sbk s
Hi. Chaitanya,
 I will give you a suggestion try that if it doesn't help you I will give you the code. Query your related attachments,  all attachments has predefined urls,grab the base URL and refer them in loop

All Answers

bk sbk s
Hi. Chaitanya,
 I will give you a suggestion try that if it doesn't help you I will give you the code. Query your related attachments,  all attachments has predefined urls,grab the base URL and refer them in loop
This was selected as the best answer
chaitanya Krishna 19chaitanya Krishna 19
VF
<apex:attribute name="recordId" description="This is the recordId of the record where files would be attached"

        type="String" required="false" assignTo="{!sobjId}"/>
<apex:form >
<apex:repeat value="{!file}" var="fId">
<apex:image url="/servlet/servlet.FileDownload?file={!fId}" width="110"/> &nbsp;&nbsp;&nbsp;
</apex:repeat>
</apex:form>

Controller
Public Class displayImageExtension {

    String recId;
    
    public displayImageExtension(ApexPages.StandardController controller) {
        recId = controller.getId();    
    }
    
    public String getFileId() {
        String fileId = '';
        List<Attachment> attachedFiles = [select Id from Attachment where parentId =:recId ];
        if( attachedFiles != null && attachedFiles.size() > 0 ) {
            fileId = attachedFiles[1].Id;
        }
        return fileId;    
    }
}


I want to loop through all the files and display dynamically,all the images, where here i am mentioning the Array[] size manually..

Hope you got what am i am trying to say.....