How to Resize an Image in Salesforce Flow Text Template?

How to Resize an Image in Salesforce Flow Text Template?

On March 20, 2025, Posted by , In Salesforce, By ,, , With Comments Off on How to Resize an Image in Salesforce Flow Text Template?

Question

I have created a text template in Salesforce Flow and tried to add an image in it to send via email. The image is inserted using the following code:

<img src="{!URL}" />

However, when I view it in the rich text editor, the image displays at its original, large size. Additionally, when I switch back to the HTML view, the width and height attributes that I added to resize the image are automatically removed. What might be causing this issue, and how can I successfully resize the image within the text template?

Answer

In Salesforce Flow Text Templates, when you add an image using the <img> tag, Salesforce often strips out or does not preserve certain attributes like width and height, especially when toggling between the rich text and HTML views. This happens because the rich text editor may attempt to automatically adjust or “clean” the content, potentially removing the inline styles or attributes you’ve added to control the image size.

However, you can still control the image size by using inline CSS within the style attribute of the <img> tag, which is more likely to be retained across both views.

For instance, you can add the following code to resize your image:

<img src="{!URL}" style="width: 300px; height: auto;" />
  • width: 300px;: This sets the width of the image to 300 pixels.
  • height: auto;: This ensures that the image maintains its original aspect ratio, meaning the height will scale automatically based on the width.

This inline style should persist when switching between the rich text and HTML views because the style attribute is generally respected in both modes.

Additional Considerations:

  1. Ensure the Image URL is Correct: When using an image URL, double-check that the URL points to a valid, publicly accessible location, as incorrect or broken links will cause the image not to display in the email.
  2. Check for Limitations: If you’re using Salesforce Classic or an older version of Flow, some behaviors may vary, and styling might not always apply. In such cases, check if there are any system updates or settings that might affect the rendering of HTML.
  3. Alternative Method: If you need further control over the image size or if the style attribute doesn’t seem to work, consider uploading the image as a Salesforce File or Static Resource and referencing it in the email template. This approach can sometimes give you more flexibility with how the image is displayed.

By using inline CSS, you’re applying styling directly to the image tag, which should prevent it from being stripped out or modified when toggling views. If this still doesn’t work as expected, Salesforce may have limitations based on the version or environment you’re using.

Real-Time Project-Based Salesforce Course to Kick Start Your Career

Our Salesforce Course is designed to offer a thorough understanding of the Salesforce platform, equipping you with the essential skills to excel in the CRM industry. The program includes important modules like Salesforce Admin, Developer, and AI, seamlessly combining theoretical knowledge with practical application. By working on real-world projects and assignments, you will develop the expertise to confidently address complex business challenges using Salesforce solutions. Our expert instructors ensure you gain both technical competence and industry-relevant insights to succeed within the Salesforce ecosystem.

Along with technical expertise, our Salesforce Training in Ajmer provides personalized mentoring, certification guidance, and interview preparation to help boost your career. You’ll have access to comprehensive study materials, hands-on project experience, and one-on-one support throughout your journey. By the end of the course, you’ll be prepared for certification exams and equipped with the practical problem-solving skills that employers value. Start your Salesforce career with us and explore a world of exciting opportunities. Enroll for a Free Demo now!

Comments are closed.