Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
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
Solved! Go to Solution.
var imageName = "mediaEntityName";
var result = "";
if (MediaEntities[imageName]) {
result = "Media entity already exists";
}
else {
result = "Media entity does not exist";
}
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
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
var imageName = "mediaEntityName";
var result = "";
if (MediaEntities[imageName]) {
result = "Media entity already exists";
}
else {
result = "Media entity does not exist";
}
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
Thank you .
How to copy the image file from SystemRepository to FileRepository. My image file is available at SystemRepository .
Could you please suggest?