cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to assign the Image to Image widget

SOLVED
Highlighted
vi1
Level 7

How to assign the Image to Image widget

Hi,

 

I want to assign the Image to Image Widget. How to achieve.

Image is available in the SystemRepository

In Below service,I am loading the image and return the Image type

 

var params = {

path: MyImagefullpath /* STRING */

};

var result = Things["SystemRepository"].LoadImage(params);  // Here result type is Image type

 

In Mashup , I am trying to bind the result value to Image Widget. It is not accepting.

Could you please advise how to assign the image(Image in SystemRepository) to Image Widget. 

 

Thank You

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to assign the Image to Image widget

var imageName = "mediaEntityName";

var result = "";

if (MediaEntities[imageName]) {
  result = "Media entity already exists";
}
else {
  result = "Media entity does not exist";
}

6 REPLIES

Re: How to assign the Image to Image widget

Hi,

 

The input for the Image widget needs to be of type IMAGELINK and it looks like this: /ThingWorx/MediaEntities/imageName

 

Use the image returned from LoadImage service as input for creating a media entity.

 

// create a media entity 
var paramsCreateMediaEntity = {
  name: imageName /* STRING */,
  content: loadImageResult /* IMAGE */
};
Resources["EntityServices"].CreateMediaEntity(paramsCreateMediaEntity);

// output the source URL of the media entity which can be used as input for the image widget
var result = "/Thingworx/MediaEntities/" + imageName

Re: How to assign the Image to Image widget

Thank you for the solution. Its working for me.

 

How to check the condition if Media entity with same name available or not before creating media entity.

 

Thank you

Re: How to assign the Image to Image widget

var imageName = "mediaEntityName";

var result = "";

if (MediaEntities[imageName]) {
  result = "Media entity already exists";
}
else {
  result = "Media entity does not exist";
}

Re: How to assign the Image to Image widget

Thank you very much for response. 

Re: How to assign the Image to Image widget

Hello,

 

You don't need to create a Media Entity if you already have the image on the FileRepository (if the given user has access to the FileRepository), also won't be good that any user can create a Media Entity...  You can directly link to a FileRpository file/image: /Thingworx/FileRepositories/"+fileRepositoryName+"/"+fileImagePath

 

Regards

Re: How to assign the Image to Image widget

Thank you .

 

How to copy the image file from SystemRepository to FileRepository. My image file is available at SystemRepository . 

Could you please suggest?