Reputation: 382
Can anybody help me to upload an image programmatically into a media picker in Umbraco 7 back office content page.
I have added the user submitted images into the media library. Also I can upload the images to an "upload" property type in the same content page. But as I am a newbie with Umbraco. I dont know how to add images to media picker. I am following MVC format.
Any help would be appreciated.
Upvotes: 2
Views: 2566
Reputation: 382
Finally I got it after some trial and runs. It was so simple. Just assign the created media Id into the corresponding property value of page. Like following:
doc.getProperty("image").Value = media.Id;
And if you need to add more than one items then:
Iterate each media IDs and make a comma separated string
imgIdList = imgIdList + "," + medid.Id;
then assign the comma separated string to the property value.
doc.getProperty("image").Value = imgIdList;
Hopes it will help somebody who are having the same problem
Upvotes: 2