Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hi,
i am trying to set the image in media entity dynamically, using following code snippet :
var params = {
url: path /* STRING */,
};
// result: IMAGE
var result = Resources["ContentLoaderFunctions"].LoadImage(params);
getting below exception:
clientprotocolexception null
Any new suggestion for doing it?
Thanks in advance!
What are you passing in as the path?
Assuming you already have a media entity named "TestMedia", here's an example of how to make it work via service. You may input a url and plug it in, you may also create an entity using a snippet, but here's the general idea and a hardcoded example that works. Let me know if you need any further details.
var params = {
url: 'https://pbs.twimg.com/profile_images/447374371917922304/P4BzupWu.jpeg' /* STRING */,
};
// result: IMAGE
var image = Resources["ContentLoaderFunctions"].LoadImage(params);
var params = {
name: 'TestMedia'/* STRING */,
content: image
};
// no return
Resources["EntityServices"].UpdateMediaEntity(params);