Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

To set a new profile picture, use the following API:

canvas.setProfileImageSrc (<Image Source>, <Target ID to set the source>);

Example

//Sample HTML image element is as follows:
	<img data-item-id="ct-pic" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/==">

/Here, img is the image tag, data-item-id is the attribute (element ID), and Canvas default value for this attribute is 'ct-pic'. 
If you want the picture to display in the default picture placeholder (element ID) provided by Canvas, use 'ct-pic'. If you want the profile picture to be displayed anywhere else in your application, you must provide the unique value of your application's element ID (for example, myprofile-pic) in your template./
 
//Usage of the API based on the above HTML image element. The image here is set by providing the base64 format as the image source. 
	ct.setProfileImageSrc("data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/===","ct-pic");
 
//Usage of the API based on the above HTML image element. The image here is set by providing the image URL format as the image source. 
	ct.setProfileImageSrc("http://localhost:7005/ctmodelhouse/images/imgpanel/myimage.jpg","ct-pic"); 


The code has two arguments:

  • Image source (argument 1): This is a mandatory argument. You must provide the data source in the base64 format or the URL format.
  • Target ID to set the data source (argument 2): This is an optional argument. The image element data-item-id value is given as the argument.If you want the picture to display in the default picture placeholder (element ID) provided by Canvas, use 'ct-pic' as the argument. If you want the profile picture to be displayed anywhere else in your application, you must provide the unique value of your application's element ID (for example, myprofile-pic) in your template as the argument.

 

  • No labels