Skip to main content
added 25 characters in body
Source Link
sfdcfox
  • 501.8k
  • 21
  • 473
  • 828

You have somehow embed the binary data into the field. Here's one way:

trigger Update_image on FeedItem (after insert) {
    id Travelid ;
    blob img; // Just binary data, thanks!
 List<Object__c> lst = new List<Object__c>();

         For(FeedItem  f : Trigger.new){
            Travelid = f.parentid;
             img = f.ContentData;
          }

for(Object__c i :[select id,image__c from Object__c where id=: travelid]){
   i.image__c = '<img src="data:image/jpeg;base64,'+EncodingUtil.base64Encode(img)+'"></img>';
   lst.add(i);
}
   update lst ;
}

Note that I've only copied/pasted your code (you may still have other issues here), but the idea is that you have to build an img tag yourself. You're limited to 64k of content

Edit:

So I just tried it, so you might also look into uploading images intoand salesforce automatically converts the image into a rtaImage servlet, although I haven't found any decent documentation on that (someone please feel freefile after saving. You can query the data back to add a link)see the changed image source. It'd be nice if this was clearly documented somewhere.

You have somehow embed the binary data into the field. Here's one way:

trigger Update_image on FeedItem (after insert) {
    id Travelid ;
    blob img; // Just binary data, thanks!
 List<Object__c> lst = new List<Object__c>();

         For(FeedItem  f : Trigger.new){
            Travelid = f.parentid;
             img = f.ContentData;
          }

for(Object__c i :[select id,image__c from Object__c where id=: travelid]){
   i.image__c = '<img src="data:image/jpeg;base64,'+EncodingUtil.base64Encode(img)+'"></img>';
   lst.add(i);
}
   update lst ;
}

Note that I've only copied/pasted your code (you may still have other issues here), but the idea is that you have to build an img tag yourself. You're limited to 64k of content, so you might also look into uploading images into the rtaImage servlet, although I haven't found any decent documentation on that (someone please feel free to add a link).

You have somehow embed the binary data into the field. Here's one way:

trigger Update_image on FeedItem (after insert) {
    id Travelid ;
    blob img; // Just binary data, thanks!
 List<Object__c> lst = new List<Object__c>();

         For(FeedItem  f : Trigger.new){
            Travelid = f.parentid;
             img = f.ContentData;
          }

for(Object__c i :[select id,image__c from Object__c where id=: travelid]){
   i.image__c = '<img src="data:image/jpeg;base64,'+EncodingUtil.base64Encode(img)+'"></img>';
   lst.add(i);
}
   update lst ;
}

Note that I've only copied/pasted your code (you may still have other issues here), but the idea is that you have to build an img tag yourself.

Edit:

So I just tried it, and salesforce automatically converts the image into a rtaImage file after saving. You can query the data back to see the changed image source. It'd be nice if this was clearly documented somewhere.

Source Link
sfdcfox
  • 501.8k
  • 21
  • 473
  • 828

You have somehow embed the binary data into the field. Here's one way:

trigger Update_image on FeedItem (after insert) {
    id Travelid ;
    blob img; // Just binary data, thanks!
 List<Object__c> lst = new List<Object__c>();

         For(FeedItem  f : Trigger.new){
            Travelid = f.parentid;
             img = f.ContentData;
          }

for(Object__c i :[select id,image__c from Object__c where id=: travelid]){
   i.image__c = '<img src="data:image/jpeg;base64,'+EncodingUtil.base64Encode(img)+'"></img>';
   lst.add(i);
}
   update lst ;
}

Note that I've only copied/pasted your code (you may still have other issues here), but the idea is that you have to build an img tag yourself. You're limited to 64k of content, so you might also look into uploading images into the rtaImage servlet, although I haven't found any decent documentation on that (someone please feel free to add a link).