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
dai tran 6dai tran 6 

Why can't display image on public site from Static Resouce?

     This my code display image: 
 
<apex:image width="100p" height="100p" value="{!URLFOR($Resource.ProductImage, 'ProductImage/' & row.ImageName__c)}"></apex:image>


If i login to salesforce and run it display ok.
View html of control:
<img src="/resource/1528944622000/ProductImage/ProductImage/1.jpg" height="100p" width="100p">



If i not login to salesforce and run, it can't display image.
View html of control:
<img src="/demo1/resource/1528944622000/ProductImage/ProductImage/" height="100p" width="100p">

i had set Cache Control of  resource [ProductImage] is Public
Why can't display image on public site from Static Resouce?
                
              
bhanu_prakashbhanu_prakash
Hi Dai,
Mark as best answer, If it resloves !!
I ensured the following things, and was able to make an .xls file attached to a document downloadable on a sites page: 
1. In the Sites Profile ("public access settings"), enable Read access to Documents (You indicate that this is already the case) 
2. Edit the folder in which the document is stored, and ensure that the Sites profile has access to the folder. To do this, I went to Admin setup ---> Manage Users ---> Public Groups and created a group consisting of ONLY the User defined by my Sites profile. You can then add this "group" to the permissions on the folder. 
Use <apex:outputLink> and in the value put "/servlet/servlet.FileDownload?file=(your docs ID here)" 
Hope this helps.

check these link
https://developer.salesforce.com/forums?id=906F000000099UoIAI
Mark as resloved if it helps :) :)
Thanks, 
Bhanu Prakash
visit ForceLearn.com  (https://www.forcelearn.com)  ​ 
dai tran 6dai tran 6
I had set allow access in "public access settings"
This is my query:
​select name,price__c,imagename__c,Product_Code__c from MyProduct__c
I try display value of them:
               <apex:column value="{!a.ImageName__c}"/> 
                <apex:column value="{!a.Product_Code__c}"/> 
                <apex:column value="{!a.Name}"/> 
                <apex:column value="{!a.Price__c}"/> 
2 columns: Product_Code__c, Name display ok.
​2 column: ImageName__c , Price__c can't display.
bhanu_prakashbhanu_prakash
Hi dai,
if ImageName__c , Price__c can't display these both are image files issue with your code,
check rightclick on output page and click on inspect check whether image space is rendering or not in UI level.
If yes please check below link 
https://developer.salesforce.com/forums/?id=906F0000000fz6CIAQ

Mark as resloved if it helps :) :)
Thanks, 
Bhanu Prakash
visit ForceLearn.com  (https://www.forcelearn.com)  ​ 
dai tran 6dai tran 6
If  login salesforce and run Preview, 4 columns display ok.
If run by link publick, only ​2 column: ImageName__c , Price__c can't display.
dai tran 6dai tran 6
<img src="/demo1/resource/1528944622000/ProductImage/ProductImage/" height="100p"width="100p">
If debug on Browers and change src="/demo1/resource/1528944622000/ProductImage/ProductImage/1.jpg" , image display ok.
My problem is why can't get value of ImageName__c and Price__c, if run by public link.
dai tran 6dai tran 6
This is full code:
Controller:
public class TestController {
    public List<MyProduct__c> MyProducts {get;set;}
   
    public string searchstring {
        get{
            if (searchstring==null) searchstring = '';
            return searchstring;
           }
        set;} 
    public TestController()
    {
       search();
    }
    
   public void search(){ 
        string searchquery='select Product_Code__c,name,price__c,imagename__c from MyProduct__c where name like \'%'+searchstring+'%\' Limit 20'; 
        MyProducts= Database.query(searchquery);        
       
   } 
}

home page:
<apex:page controller="TestController"  >
   <apex:form >       
     <div align="center">
           <apex:inputText style="width: 360px; height: 25px" value="{!searchstring}" label="Input"/> 
        <apex:commandButton value="Search" action="{!search}" /> 
      </div>            
    
      <apex:pageBlock title="Search Result"> 
              
            <apex:pageblockTable value="{!MyProducts}" var="a"> 
                <apex:column >
                    <apex:image width="100" height="100" value="{!URLFOR($Resource.ProductImage, 'ProductImage/' & a.ImageName__c)}"></apex:image>
                </apex:column>
                 <apex:column value="{!a.ImageName__c}"/> 
                <apex:column value="{!a.Product_Code__c}"/> 
                <apex:column value="{!a.Name}"/> 
                <apex:column value="{!a.Price__c}"/>              
            </apex:pageblockTable>         

        </apex:pageBlock> 
   </apex:form>   
</apex:page>

Result Click Preview:
User-added image

Result run on public site:
User-added image