Adding a field to display an Image. e.g. Product Photo

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Adding a field to display an Image. e.g. Product Photo

  • Comments 7
  • Likes

Below is a screen that shows the product configuration area in Sage CRM. 

To create this field I added a new field to the NewProducts table within the administration screens.

I called my field 'prod_productImage' and used the Entry Type 'WWW URL'. The field has a length of 200 and an entry width on 100.

I then added the field to the New Product screen 'ProductSummary'.

I put the field on a new line and allowed it to stretch over 5 columns.

I also added the following script into the custom content box.

[code language="Javascript"]
<script>
crm.ready(function () {
var myfield = crm.fields("prod_productImage")
if (myfield.getMode()=="view")
{
myfield.urlToImage({src:myfield.value(),width:100})
}
})
</script>
[/code]

The image is entered as a URL.

E.g.

http://[img].[myserver]/images/I/81ONPcrUG7L._SL1500_.jpg

Once the image has been entered and saved field shows the URL as an image.

Comments
  • Thanks a lot for the step by step guide. Worked Perfectly.

  • Jeff

    Is there a way to maintain the original size of the image once loaded, i can see that one can define the width, i would assume similary the height. What would be the best way to maintain the original size of the image.

  • Kannan

    Imagine there is an image created.      

    img src="/crm73/Themes/img/ergonomic/Icons/company.png" hspace="0" border="0" align="TOP" id="myimage" title="" />

    You can get the actual dimensions using the properties naturalHeight and naturalWidth.  E.g.

    var myimage = document.getElementById("myimage")

    myimage.naturalWidth

    myimage.naturalHeight

  • Hi Jeff,

    Can we add this image in a quote document template ( html or Word)?

  • Jerome

    In the example above the image is not held in the database - only the path is used.  You can certainly include the path in the email template to add the image to outbound emails.  But this link to an external file doesn't work within the document merge as it expects the image file to be included in the document.

  • Jeff

    Is there any way I can add a field to the pricing block? I need to add NRC and so far no luck

  • Do you mean Non Recurring Costs by NRC?  How do you want this to appear? - It is best if you start a new thread in one of the forums, please.