Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Sørensen 304 posts 650 karma points
    Aug 07, 2010 @ 00:31
    Paul Sørensen
    0

    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

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 07, 2010 @ 04:04
    Tom Fulton
    0

    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

     

  • Paul Sørensen 304 posts 650 karma points
    Aug 07, 2010 @ 09:32
    Paul Sørensen
    0

    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

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 09, 2010 @ 18:29
    Tom Fulton
    0

    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:

    var e = {{ outVal: linkLink }};
    mc_{0}mediaChooser.SaveSelection(e);

     

  • Paul Sørensen 304 posts 650 karma points
    Aug 09, 2010 @ 21:00
    Paul Sørensen
    0

    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

     

  • Paul Sørensen 304 posts 650 karma points
    Aug 12, 2010 @ 08:15
    Paul Sørensen
    0

    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

  • marthin 87 posts 106 karma points
    Oct 14, 2010 @ 17:06
    marthin
    0

    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?

  • mfeola 117 posts 221 karma points
    Oct 29, 2010 @ 20:11
    mfeola
    0

    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.

  • marthin 87 posts 106 karma points
    Oct 30, 2010 @ 01:40
    marthin
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft