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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

How to set image in media entity dynamically?

done11
1-Newbie

How to set image in media entity dynamically?

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!

2 REPLIES 2
ttielebein
12-Amethyst
(To:done11)

What are you passing in as the path?

posipova
20-Turquoise
(To:done11)

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);

Top Tags