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
PipDennoPipDenno 

How do I use the commandbutton attibute IMAGE. I just see a broken image.

When useing the <apex:commandbutton> component how do I use the IMAGE option to show an image of a button I have which is stored in the static resources section of SFDC.  The button is called 'Submit_Button_Green'.

 

I am trying to use something like:

 

<apex:commandButton image="Submit_Button_Green" action="{!saveNSSEForm}" />         


Any help is appretiated.

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

To fetch ayy static resource your syntax should be 

 

1)If you have directly made image a Static Resource :

<apex:image url="{!$Resource.TestImage}" width="50" height="50" /> 

 

2)If you have a zip file as resource and inside it a folder and image in folder 

    <apex:image url="{!URLFOR($Resource.TestZip, 'images/Bluehills.jpg')}" width="50"height="50" />

 

   Here : TestZip is Zip file as Statiuc Resource

                images : is Image folder in zip file

                Bluehills.jpg : is the image file

All Answers

Shashikant SharmaShashikant Sharma

To fetch ayy static resource your syntax should be 

 

1)If you have directly made image a Static Resource :

<apex:image url="{!$Resource.TestImage}" width="50" height="50" /> 

 

2)If you have a zip file as resource and inside it a folder and image in folder 

    <apex:image url="{!URLFOR($Resource.TestZip, 'images/Bluehills.jpg')}" width="50"height="50" />

 

   Here : TestZip is Zip file as Statiuc Resource

                images : is Image folder in zip file

                Bluehills.jpg : is the image file

This was selected as the best answer
PipDennoPipDenno

This works when showing an image but not not seem to be accepted when using within the image attribute of the command button.

 

<apex:commandbutton image="?????" value="" action="{!submit}" /> 

PipDennoPipDenno

I have managed to get it to work.  I played around with the format and the following now seems to have worked.

 

<apex:commandbutton image="{!URLFOR($Resource.Submit_Button_Green)}" ........ />

PipDennoPipDenno

Thanks for your help.