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
simsonsimson 

cant Show contact images in customer portal

Is it possible to show the images on the customer portal?

The requirement is to show  portal users a photograph of their Company contact person.

In the Company contact's attachment section i have attached a image as an attachment.

Once the portal user clicks on the link to show the companys contact person a visual force opens up to show the contact photo.

The visual force code is as follows:

<apex:page controller="ViewContactImages" showHeader="false"> 
Showing the Image with Id {!mainImage}
<apex:image url="{!URLFOR($Action.Attachment.Download, mainImage)}"/>
</apex:page>

 

The controller is as follows:

public class ViewContactImages{

    public Id mainImage;
    public Id getMainImage(){
    	system.debug('getting the mainImageId =='+mainImage);
    	return mainImage;
    }
    
    public void setMainImage(Id imageId){
    	this.mainImage = imageId;
    }
    
    public ViewContactImages(){
        mainImage = 
        [select Id from Attachment 
        	where ParentId = :ApexPages.currentPage().getParameters().get('conId')].Id;
    }
}

 When i get into the customer portal and get to the visual page that shud show the image i cannot see the image.

Any heads up appreciated.

Thanks'

Simson

WesNolte__cWesNolte__c

Hey

 

Are you sure that your object is viewable for that customer portal profile? You might also want to check field level security for that object in the CP profile.

 

Wes

simsonsimson

Thanks Wes for your reply.

Yes it is the "Contact" Object and it has read,create and edit  permissions on it.

Any other thing that i need to check?

 

Thanks

Simson

WesNolte__cWesNolte__c

Other things to check are:

 

 

  • Is your debug message giving a result? (I'm guessing yes since you don't get an exception)
  • Examine the source html for the generated page. What's in the <img> tag?
  • You could also check field level security under 'Standard Field-Level Security', but I don't think that's your issue.
  • What happens if you view the page inside a salesforce session i.e. log in as your user and view the page "inside" salesforce.

 

 

Wes

simsonsimson

1. Yes,The debug message gives me the Id that is needed.

2. The view source on the page gives the following :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    Showing the Image with Id = 00PR0000000Hk74MAC
<html><head></head><img src="/servlet/servlet.FileDownload?file=00PR0000000Hk74MAC" /></html>
3.  The Parent object for the attachment is Contact having Read, Edit and Create Permissions.
4.  Even Viewing  the visual force page inside a salesforce session does not show up the image.
 
Any other thing that i should see?
 
Regards,
Simson
WesNolte__cWesNolte__c

Hmmm, trickier and trickier.

 

If you browse to the attachment within salesforce you'll arrive at a screen with a link that says 'Click here to view this file'. Does clicking that show the image properly? Look at the url, does it match the URL inside of the <img> tag?

 

Wes

simsonsimson

hi Wes,

Thks again for your quick response.

I need to show up the image when the page loads.i do not want to link which says "Click here to view this file".

When i get  on to the page i see the page without the image.

 

 

 

WesNolte__cWesNolte__c

Yeah I didn't mean link to this page, just see if you can see the image from there. If you can't see the image from that link then the image might be damaged, or possibly something has gone wrong on the Salesforce side. Can you upload another image in a different format and then try?

simsonsimson

As this image is based on the contact i tried to add another image for a different contact and checked of the image was visible for a different contact,but the image did not show up for the other contact too.I even tried to change the image file format from jpg to gif and check if it works but that dint work either :(

WesNolte__cWesNolte__c

I think I'm out of ideas then. I've done the same in one of my Org i.e.

 

Found a PNG image that worked in my documents.

Added this as an attachment to a contact.

Clicked on the the attachment in the contact's related list.

Clicked on 'Click here to view this file'.

 



I then see the image. If you're admin and have full rights I can't think of anything else to check. Sorry.

 

Wes

simsonsimson

oh . OK. When i go to the screen which u have published and click on the 'Click here to view this file'.i can see the image too.I am the admin  and have rights on the system.its only on the visual page that i cannot see the image.'

 

Simson

simsonsimson

i can see the image when i click on the screen which u have shown below..its only when i get intp the visual page i cannot see the image.i am the admin and have acess rights.

 

Simson

WesNolte__cWesNolte__c

Okay so check the URL when you click 'Click here to view this file'. Is it the same as the URL within the <img> tag?

 

For me it's: /servlet/servlet.FileDownload?file=00PS0000000J9PB in the first case. 

 

Start by viewing the page as a logged in admin and compare the two URLs.

 

Wes

simsonsimson

Clicking on "Click here to view this file" gives the following url - /servlet/servlet.FileDownload?file=00PR0000000HkYy.

The url within the image tag is /servlet/servlet.FileDownload?file={!mainImage} where the ={!mainImage} is 00PR0000000HkYyMAK.

i even tried to do a substring(0,15) on the image id so that i have only 15 digits in the image Id.

And yes i compared the 2 urls by logging in as admin.

 

Regards

Simson