A sample Visual Force page along with the custom controller. For this example, I have stored an image in the Document object with name"sample pic". You can add this VF page to layout of the page.
VF Page
<apex:page controller="ImageController" showheader="false" sidebar="false">
<apex:form>
<apex:image url="{!imageURL}">
</apex:image></apex:form>
</apex:page>
Apex Controller
public with sharing class ImageController {
public String imageURL{get;set;}
public ImageController()
{
imageURL='/servlet/servlet.FileDownload?file=';
List< document > documentList=[select name from document where
Name='SamplePic'];
if(documentList.size()>0)
{
imageURL=imageURL+documentList[0].id;
}
}
}
Update
VF Page
Here is a working solution with custom Event object with a Logo field. I assume the URL is https://<your salesforce URL>/apex/logodisplay?id=a0Li000000L03KU
. Where the a0Li000000L03KU
is a event id.
<apex:page standardController="Event__c" extensions="ImageController" showheader="false" sidebar="false">
<apex:form >
<apex:inputHidden id="eventLogo" value="{!Event__c.Logo__c}" />
<apex:image url="{!imageURL}"></apex:image>
</apex:form>
</apex:page>
Apex Controller
public with sharing class ImageController {
public String imageURL{get;set;}
private Event__c eventObject;
public ImageController(ApexPages.StandardController controller) {
eventObject = (Event__c)controller.getRecord();
imageURL='/servlet/servlet.FileDownload?file=';
String logo_name = eventObject.Logo__c;
List< document > documentList=[select name from document where Name=:logo_name];
if(documentList.size()>0)
{
imageURL=imageURL+documentList[0].id;
}
}
}
So the main problem is Merge fields only work in VF pages. If you check this line https://github.com/tylerzika/taskCalendar/blob/master/app/task/task-calendar-controller.js#L32
You have a merge field which when moved to static resource just evaluates to a string, whereas when you use in VF page , it actually renders a value.
So in VF page you can do something like
var remoteGetTask = '{!$RemoteAction.TestController.getTasks}';
And in the static resource file
$scope.getTaskData = function() {
Visualforce.remoting.Manager.invokeAction(
remoteGetTask,
window.$userId,
function(result, event)
{
$scope.$apply(function() {
console.log(result);
});
}
);
}
Best Answer
Apex code for saving the chunks of file.