1

Is it possible to resize images in a Rich Text Field?

We need to add images to a rich text field we have, but we found out we couldn't do any resizing.

Is resizing possible in Salesforce rich text field? Or is this a limitation?

Edit: This is the rich text editor that I see: enter image description here

2

You can do it with Apex. If you have only 1 image in the text you can use the following sample code.

String contactId;
Contact c = [
        SELECT Id, Picture__c
        FROM Contact
        WHERE Id = :contactId
];

c.Picture__c = c.Picture__c.replace('<img', '<img style="height: 256px"');

update contacts;

Note: update SObject name and field name

If you have more than 1 image you might want to add better search strings

| improve this answer | |
  • Presumably that is lost if further interactive editing is done? – Keith C Sep 25 '19 at 9:09
  • No, for some reason it is saved. Even when you update the content of the field – ytiq Sep 25 '19 at 10:27
  • Good to know - thanks! – Keith C Sep 25 '19 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.