Thanks to a good steer in this thread I have managed to get an image into an email template that I can package up and put in any org.

My design:

  • Stores the image as a document
  • Uses a component with a custom controller
  • The controller executes a query and gets the ID of the image and
  • The Component then displays the image by doing:

    <apex:component controller="ImageCustomController" access="global">
        <apex:attribute name="height" description="Id for image" type="String"/>
        <apex:image value="{!LEFT($Api.Partner_Server_URL_140, FIND('.com/',$Api.Partner_Server_URL_140)+3)}/servlet/servlet.ImageServer?id={!ImageId}&oid={!$Organization.Id}" height="{!height}"/>

All brilliant.

However, it is difficult to place something beside my component. In my template, I do:

<c:ImageComponent height="20"/>
<H1>Performance Insight</H1>

The image component takes the width of the screen. I want it to behave just like a normal where it is possible to put stuff beside it.

Note: In some cases I want stuff beside and in other cases I won't. So if put the stuff beside it into the actual component I will need to have some logic to know whether to display the extra stuff or not. Is that possible?

1 Answer 1


I believe it's because it's rendered into a <div> (which is a block element or whatever is the official name... What I mean is that divs by default occupy 100% width).

Check this explanation for "layout" attribute of <apex:component>:

The HTML layout style for the component. Possible values are "block" (which wraps the component with an HTML div tag), "inline" (which wraps the component with an HTML span tag), and "none" (which does not wrap the component with any generated HTML tag). If not specified, this value defaults to "inline".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .