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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to assign the Image to Image widget

vi1
15-Moonstone
15-Moonstone

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
cbuse
12-Amethyst
(To:vi1)

var imageName = "mediaEntityName";

var result = "";

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

View solution in original post

6 REPLIES 6
cbuse
12-Amethyst
(To:vi1)

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

vi1
15-Moonstone
15-Moonstone
(To:cbuse)

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

cbuse
12-Amethyst
(To:vi1)

var imageName = "mediaEntityName";

var result = "";

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

vi1
15-Moonstone
15-Moonstone
(To:cbuse)

Thank you very much for response. 

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

vi1
15-Moonstone
15-Moonstone
(To:CarlesColl)

Thank you .

 

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

Could you please suggest?

Top Tags