You need to sign in to do that
Don't have an account?
img SRC - correct syntax to append string
I have a text field called Test__c
public myCustomSettings__c myCustomSettings=myCustomSettings__c.getValues('PBA');
String imageid = myCustomSetting.Image_Id__c;
If i do hardcode the file ID , I see the image.
//obj.Test__c = '<img alt="comment" src="/servlet/servlet.FileDownload?file=01580000001YP3k" ></img>';
But ofcourse I don't want to hard code the id, so I did the following which doesn't display the image
pbaComment.Test__c = '<img alt="comment" src="/servlet/servlet.FileDownload?file="+commentimageid>
Can someone tell me what is the correct syntax?
Thanks.
public myCustomSettings__c myCustomSettings=myCustomSettings__c.getValues('PBA');
String imageid = myCustomSetting.Image_Id__c;
If i do hardcode the file ID , I see the image.
//obj.Test__c = '<img alt="comment" src="/servlet/servlet.FileDownload?file=01580000001YP3k" ></img>';
But ofcourse I don't want to hard code the id, so I did the following which doesn't display the image
pbaComment.Test__c = '<img alt="comment" src="/servlet/servlet.FileDownload?file="+commentimageid>
Can someone tell me what is the correct syntax?
Thanks.
***************** step1: Created a custom setting , added the id of the image to this custom setting ***********************
***************** step2: Created an instance of the custom setting in my controller to fetch the custom setting data ***********************
***************** step3: Created a string variable , appended the custom setting field (this field holds the image id) to the File URL **************
*************** step4: Populated the long text area with the image by appending the string created in step 3 above rather than hardcoding the id ***************
myCustomSettings__c myPBA =myCustomSettings__c.getValues('nameundermanage');
String emailimageid = '/servlet/servlet.FileDownload?file=' +myCustomSettings.Email_Image_Id__c;
customobject.Test__c = '<img alt="email" src="' + emailimageid + '"></img>';
All Answers
You have to upload the image in Static resources. Then you need to add the following code in your code to <img src="{!$Resource.ImageName}"/> where image name is the Static resource name.
Please try and let me know if you need more help.
Thanks,
Raghu
obj.Test__c is a text field
***************** step1: Created a custom setting , added the id of the image to this custom setting ***********************
***************** step2: Created an instance of the custom setting in my controller to fetch the custom setting data ***********************
***************** step3: Created a string variable , appended the custom setting field (this field holds the image id) to the File URL **************
*************** step4: Populated the long text area with the image by appending the string created in step 3 above rather than hardcoding the id ***************
myCustomSettings__c myPBA =myCustomSettings__c.getValues('nameundermanage');
String emailimageid = '/servlet/servlet.FileDownload?file=' +myCustomSettings.Email_Image_Id__c;
customobject.Test__c = '<img alt="email" src="' + emailimageid + '"></img>';