[SalesForce] Image URL in Rich Text Area field Salesforce

When I get the URL for the saved image in Salesforce and viewed it shows the image as it is. Suppose below is the URL we get:

{instanceURl}/CSVerification/servlet/servlet.FileDownload?file=00P0S0000021IpKUAU

But when I use the same URL in Rich Text Area field of an object as mentioned below:

<img alt="applicationImage" src="{instanceURL}/CSVerification/servlet/servlet.FileDownload?file=00P0S0000021IpKUAU">

Image is getting displayed but not the original one, It's getting displayed in landscape mode (rotated left by 90deg).

Why image not getting displayed as it displays with URL in Rich Text Area?

Best Answer

This problem is caused by the EXIF extension in this article, combined with the fact that apparently image-rotation is, by default, 0deg, so any compliant browser isn't allowed to show the image right-side-up.

The only fix for this is to reorient the image properly by using an image manipulation algorithm capable of reordering the pixels in the file, such as using an HTML canvas in JavaScript, or by using a tool such as ImageMagick. This needs to be done before the HTML is saved to the RTA field, because a copy of the file is made at that point in time, so further changes won't be reflected in that field. There is no reliable fix other than to reorient the image, or take the image "right side up" with your camera.

Related Topic