this.dataExtractor = new DataExtractor(); this.mediaPicker = new umbraco.editorControls.mediaChooser(dataExtractor); this.ppLogo.Controls.Add(this.mediaPicker);
When I set the value of the node id, the UI used to show the name of the image being picked but after upgrading it acts as if nothing has been set.
this.mediaPicker.Value = ei.Logo;
Has the mediaChooser been changed? - do I have to used it differently now?
I have tried adding the new parameters and it looks fine, but it still doesn't solve the problem. When load the page and set the id of the node the mediaChooser acts as if nothing was set.
It looks like there's a Javascript function included with the new Media Picker to manually set the ID, called SaveSelection. This is a javascript snippet from the Related Links with Media package that sets the selected media when the Edit button is clicked:
var e = {{ outVal: linkLink }}; mc_{0}mediaChooser.SaveSelection(e);
Bydebugging through the MediaChooser I found that a Page.LoadControl failed because the Page object is null, so I think an error has been introduced here in 4.5.
I tried to fix it;
string ucPath = umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/controls/Images/ImageViewer.ascx"; Control uc = new System.Web.UI.UserControl().LoadControl(ucPath);
but then I saw that the Media property wasn't said, so obviously you also got a point, Tom - thanks for the assistance - I'll report it as an error.
and you can get the mediapicker info that was saved (if you already were able to save it somehow which is the problem of this article) if you use a dataextractor class.
MediaChooser problem in 4.5
Hi
I have implemented a custom section containing a mediaChooser in 4.0 and it has been working fine until I upgraded to 4.5.
private umbraco.editorControls.mediaChooser mediaPicker;
this.dataExtractor = new DataExtractor();
this.mediaPicker = new umbraco.editorControls.mediaChooser(dataExtractor);
this.ppLogo.Controls.Add(this.mediaPicker);
When I set the value of the node id, the UI used to show the name of the image being picked but after upgrading it acts as if nothing has been set.
this.mediaPicker.Value = ei.Logo;
Has the mediaChooser been changed? - do I have to used it differently now?
Thanks
Paul S
Hi Paul,
Yes, the Media Picker did change in 4.5 - its now using the Improved Media Picker, which has support for upload & preview.
I have never tried setting the value, but here is some code I've used to use a Media Picker in a custom datatype...hopefully it gets you going.
private mediaChooser _mediaChooser;
private PagePickerwMediaDataExtractor _mediaChooserExtractor;
_mediaChooserExtractor = new PagePickerwMediaDataExtractor();
_mediaChooser = new mediaChooser(_mediaChooserExtractor,true,true);
_mediaChooser.ID = base.ID + "mediaChooser";
... _mediaChooserExtractor.Value.ToString() ...
BTW - the true,true enables Preview & Upload
Thanks,
Tom
Hi Tom
I have tried adding the new parameters and it looks fine, but it still doesn't solve the problem. When load the page and set the id of the node the mediaChooser acts as if nothing was set.
BR
Paul S
Hi Paul,
It looks like there's a Javascript function included with the new Media Picker to manually set the ID, called SaveSelection. This is a javascript snippet from the Related Links with Media package that sets the selected media when the Edit button is clicked:
Hi Tom
I'm not quiet sure of what you mean so I'll just clarify:
After editing I save the id of the 'image node' like this
if (this.mediaPicker.Value != null)
ei.Logo = this.mediaPicker.Value.ToString(); // ex value = 1234
and it work as expected - I can see the value in the database and I can see a thumbnail of the image in th UI
When I then load the page later again it looks like this and ei.Logo contains the correct value - 1234.
this.mediaPicker.Value = ei.Logo; // ex 1234
but now I can't see the thumbnail of the image - I only see the link Choose as if nothing was selected.
- so I think that the mediachooser has got a problem in 4.5
Thanks
Paul S
HI
Bydebugging through the MediaChooser I found that a Page.LoadControl failed because the Page object is null, so I think an error has been introduced here in 4.5.
I tried to fix it;
string ucPath = umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/controls/Images/ImageViewer.ascx";
Control uc = new System.Web.UI.UserControl().LoadControl(ucPath);
but then I saw that the Media property wasn't said, so obviously you also got a point, Tom - thanks for the assistance - I'll report it as an error.
Paul S
Hi, Im just wondering if this problem has been resolved in the current release?
And a quick question, how do i set a value to the mediapicker? So that it can get the corrcet thumbnail when i load it the first time?
yeah i am wondering if this is fixed as well
and you can get the mediapicker info that was saved (if you already were able to save it somehow which is the problem of this article) if you use a dataextractor class.
Mediapicker / contentpicker in edit page in custom section.
If you follow this thread http://our.umbraco.org/forum/developers/extending-umbraco/13518-implement-improved-mediapicker-c then you might get some help. I got it working this way.
is working on a reply...