Thursday, July 2, 2009

Umbraco Package - Media Picker with Preview

I started exploring Umbraco with a background of more than 2 years website development using Sitecore CMS. I've really fallen in love with Umbraco because it's as flexible as Sitecore but is more simple, fast and it's open source product! But there was one thing that was always annoying me during work with Umbraco: when you have selected image using Media Picker you can only see the name of the media item! It's so inconvenient. And I've decided to solve this problem by extending the standard media picker with a preview of the image selected. Meet the Media Picker with Preview data type for Umbraco v4.0.1 and higher - the simple but useful package that can impove usability of Umbraco Client.

How it looks

After you have selected an image using Media Picker With Preview the image preview is shown



What do you need to make it work is just follow the steps below:

(IMPORTANT: Package is for Umraco v4.0.1 and higher)

1. Download the Media Picker With Preview package from here.
2. Install dowloaded package in Umbraco Client (Developer -> Packages -> Install Local Packages)
3. And that's it! Now you can use new "Media Picker with Preview" data type.

Configuration

You can make some configuration of Media Picker with Preview.
The Maximum Width and Maximum Height of the preview area can be changed (Developer -> Data Types -> Media Picker with Preview). The default values are 500 for width and 200 for height.



Applying to the existing media fields

If you want to apply the Media Picker with Preview to the existing fields of Media Picker type you should change the "Database datatype" setting of Media Picker with Preview data type to "Integer" ("NText" is set by default) and then just change the data type property of your fields to Media Picker with Preview. All the selected images are selected after applying new datatype!

I hope this simple package will help everyone using Umbraco.

Source code is available here.

PS. Please leave you comments and feel free in your feedback.

10 comments:

  1. If it allow to upload new image into media section it will be great control and can solve issue 12788 from codeplex. I try paste link, but without luck :-(

    ReplyDelete
  2. Unfortunately it doesn't have upload function. It's just a small but useful adjustment to standard media picker.
    Upload will probably be implemented in the next version.

    ReplyDelete
  3. volandzz,

    Awesome data type, just using it now on new site.

    Thanks

    Ismail

    ReplyDelete
  4. Although the aspx and dll are in place after installing the package, clicking "Choose..." on a document that implements this type as a property does nothing.

    Is this no longer compatible with the latest version of umbraco?

    ReplyDelete
  5. milksama,
    This feature is included into standard Media Picker datatype in new Umbraco 4.5
    So there is no sense to make my package compatible with it.

    ReplyDelete
  6. I am having the same problem as milksama and your answer does not make any sense to me. When I install the control and select "Choose...", I simply get a javascript error from ~/umbraco/editContent.aspx ... I am running Umbraco 4.5.2 on .NET 3.5

    ReplyDelete
  7. Starting from the version 4.5 Umbraco has the Preview function for the standard Media Picker data type.
    You can activate Preview function in section Developer by the path Data types -> Media Picker. Just check the checkbox "Show preview" and that's it!
    So, I think there is no any sense to use my custom data type in new versions of Umbraco.

    ReplyDelete
  8. Hi there, thanks for your Preview tool. We're just now getting an error on one of our websites (Umbraco 4.0.3 installation) that we can't figure out. In Firefox, the Media pop-up list refuses to load when selecting "Choose", and we're getting this error when we go to any node that has a Media Picker Preview.

    [FormatException: Input string was not in a correct format.]
    System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7471335
    System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
    volandzz.MediaPickerWithPreview.MediaPickerPreview.Page_Load(Object sender, EventArgs e) +202
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    System.Web.UI.Control.LoadRecursive() +50
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

    Unfortunately the database is a VistaDB which is not easy to traverse through and look for any issues. Is there anything you can think of that would cause this error? Thanks!

    ReplyDelete
  9. Hi,

    When you upgrade to a newer version of Umbraco the Media Picker With Preview doesn't work. So I wrote a blog post about changing from your awesome Media Picker to the built-in Media Picker. Hope its cool :)

    http://betafirm.com/upgrading-from-media-picker-with-preview-to-the-built-in-media-picker/

    Cheers
    Bjørn

    ReplyDelete