You need to sign in to do that
Don't have an account?
jaelee125
Re-size image on rich text area field
I'm trying to re-size the image on a rich text area field. I got it working by adding style to img tag on the rich text area field.
For example:
Contact contact = [ SELECT Id, Picture__c FROM Contact WHERE Id = 'someId' ];
contact.Picture__c = contact.Picture__c.replace('<img', '<img style="height: 256px"');
Ideally we would like to use max height so images smaller than 256px won't get stretched out. However, max-height doesn't seem to work. If I add max-height, it clears it.
If I add max-height it saves it as style="".
There are no errors in the log. Using the query editor in the dev console, if you set the value of a rich text area field to <img style="height: 20px;"></img>, it saves it as <img style="height: 20px;"></img>. However, if you set the value of a rich text area field to <img style="max-height: 20px;"></img>, it saves it as <img style=""></img>.