I have DAMP property on my doctype the data is stored as xml. How do I go about adding an existing image in the media section the document using Umbraco api?
There aren't any real samples for this, but there might be some usefull things in the source code.
In DigibizAdvancedMediaPicker.ascx.cs there is method called GetXML() and GetMediaElements(string id). These are the methods which will store the selected images as media xml.
In DAMP_ApplicationBase.cs there is a method called UpdateDAMP(Media media, bool deleteMediaItem). This method makes sure if you update an image in the media section it also gets updated on the documents which store the media xml.
So hopefully you can use this code to add an existing image.
Cool many thanks. Just interested in first suggestion as I am looking to create a fieldadaptor for cmsimport and the document type has DAMP field, so will have a play with your suggestion
Just a quick note. The GetMediaElements(string id) method from my first suggestion has changed since DAMP 1.0. First I used library.GetMedia, but I changed it in DAMP 2.0 because I had some problems:
So in DAMP 2.0 I get the xml directly from the cmsContentXml table which solved it. If you want to create a fieldadaptor I suggest you use the code from DAMP 2.0, but I just wanted to let you know that DAMP 1.0 is different.
Add image to DAMP datatype using API
I have DAMP property on my doctype the data is stored as xml. How do I go about adding an existing image in the media section the document using Umbraco api?
Regards
Ismail
Hello,
There aren't any real samples for this, but there might be some usefull things in the source code.
In DigibizAdvancedMediaPicker.ascx.cs there is method called GetXML() and GetMediaElements(string id). These are the methods which will store the selected images as media xml.
In DAMP_ApplicationBase.cs there is a method called UpdateDAMP(Media media, bool deleteMediaItem). This method makes sure if you update an image in the media section it also gets updated on the documents which store the media xml.
So hopefully you can use this code to add an existing image.
Jeroen
Jeroen,
Cool many thanks. Just interested in first suggestion as I am looking to create a fieldadaptor for cmsimport and the document type has DAMP field, so will have a play with your suggestion
Many thanks
Ismail
Just a quick note. The GetMediaElements(string id) method from my first suggestion has changed since DAMP 1.0. First I used library.GetMedia, but I changed it in DAMP 2.0 because I had some problems:
http://umbraco.codeplex.com/workitem/30234
http://umbraco.codeplex.com/workitem/30235
So in DAMP 2.0 I get the xml directly from the cmsContentXml table which solved it. If you want to create a fieldadaptor I suggest you use the code from DAMP 2.0, but I just wanted to let you know that DAMP 1.0 is different.
Jeroen
Hi Ismail,
Did you succeeded in creating a fieldadaptor for cmsimport using my samples?
Jeroen
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.