Doesn't look like it, using the IMAGE formula directly. A few options I would suggest.
- as part of your normal business process, re-scale the images upon upload. Obviously depending on the process and/or personnel involved, or if they are self-service uploads, this may not be feasible.
- do a nightly / hourly / whatever rescale of all new images. This would be a pretty easy task via an API integration and the excellent ImageMagick library.
- if changing your upload process to introduce a scaling step, or a nightly rescale, is undesirable, you could introduce a middle-man server to do the scaling on the fly. So a URL like
'http://posse.force.com/photos/servlet/servlet.FileDownload?file='+LEFT(SYSTEM_Photo_Id__c,15)
becomes something more like 'http://myimagescaleserver/scale?sfid='+LEFT(SYSTEM_Photo_Id__c,15)+'&width=150'
For option 3, there is a discussion here with some interesting options, including the little tidbit that Google Docs supports dynamic image resizing which I was not aware of. Image Resizer also seems like a pretty good server option, and it's free.
EDIT: realized I left out a fourth option, which is a hack but it seems like a pretty common approach to this sort of issue. You use a sidebar component with some JavaScript (usually backed by jQuery) which looks at your page, finds the profile image (probably by combination of table location and URL), and then dynamically resizes it. It's a hack because Salesforce doesn't recommend DOM manipulation and doesn't guarantee that anything will remain the same from release to release, etc. but I've seen similar things done at several clients in the past. Here's an example of what this sort of page-manipulation component looks like.
EDIT 2: just found this thread which has what look to be pretty viable middle-man options that are already around and look pretty easy to use (and mostly free!), if you don't mind a third party processing your images.
The FeedItem has a field called RelatedRecordId which is defined as:
ID of the ContentVersion object associated with a ContentPost. This field is null for all posts except ContentPost.
For example, set this field to an existing ContentVersion and post it to a feed as a FeedItem object of TypeContentPost.
If you right click on the download link for the chatter image you get an URL for the download.
It will be something like:
https://c.na15.content.force.com/sfc/servlet.shepherd/version/download/068i0000002EqDEBQ5?asPdf=false&operationContext=CHATTER
The ID portion of the URL, 068i0000002EqDEBQ5, is the ContentVersion ID, which is the same as the RelatedRecordId on the FeedItem.
Putting it all together...
Create a custom text field on your object called Content_Version_ID__c and capture the FeedItem’s RelatedRecordId in it (code below). Construct an IMAGE formula field with the following formula:
IMAGE("/sfc/servlet.shepherd/version/download/“ & Content_Version_ID__C, "Chatter Image")
Here is the FeedItem trigger code to copy the RelatedRecordId to the custom Content_Version_ID__c field. I wrote it to work for Leads, but you can modify it for whatever Object you need.
trigger FeedItemTrigger on FeedItem (after insert) {
Map<Id, Id> possibleRelateds = new Map<Id, Id>();
for (FeedItem fi : Trigger.New) {
if (fi.RelatedRecordId != null) {
possibleRelateds.put(fi.RelatedRecordId, fi.ParentId);
}
}
Map<Id, Lead> leads = new Map<Id, Lead>();
for (FeedItem fi : [
Select Id, RelatedRecordId, ParentId
From FeedItem
Where Parent.Type = 'Lead'
And ParentId In :possibleRelateds.values()
]) {
if (fi.RelatedRecordId != null &&
possibleRelateds.get(fi.RelatedRecordId) == fi.ParentId &&
!leads.keySet().contains(fi.ParentId)
) {
Lead leadToUpdate = new Lead(
Id = fi.ParentId,
Content_Version_ID__c = fi.RelatedRecordId
);
leads.put(leadToUpdate.Id, leadToUpdate);
}
}
update leads.values();
}
As noted, this will not update to point to a newer version of the file if a newer version is uploaded.
Best Answer
Because you've enclosed
customfield__c
inside single quotes it is being treated as a string literal in your formula.You need to remove it from the single quotes and instead append it to your string to get the result you want.