More in this section

Forums / Developing with Sitefinity / Image control and libraries

Image control and libraries

8 posts, 0 answered
  1. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    26 May 2010
    Link to this post
    Hi,

    I'm trying to derive from the SitefinityImage control in order to make it able to display images, videos and flash animations. I think I have the code part figured out, however once in the wild, the Sitefinity administration only allows me to select Images libraries and images (no flv nor videos then) for the ImageUrl property.

    Do you know how I could make it be able to select any library and file ? Alternatively, I've been trying to add flv files to the Image library but

    <add name="Image" title="Image Library" defaultExtenstions=".png, .jpg, .jpeg, .gif, .flv" metaKeys="Author, AlternateText, Extension, Name, Height, Width, Size, Category, URL"></add>

    doesn't seem to work: I have the following error when trying to upload my file:
    test.flv could not be uploaded because it is not a valid browser viewable image. Image gallery should contain only browser viewable images. 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    26 May 2010
    Link to this post
    Hi Lucas,

    You should use Video or better CustomLibrary for uploading files. Currently you are trying to upload a file to Image library with a not valid extension and format. In our code we check whether the image is valid or not because it gets uploaded. Also the control uses Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ImageEditorDialog.ascx where AllowedFileExtensions are only for images - jpg,.jpeg,.gif,.png. By default the dialog opens only Image libraries. You could create a custom dialog that allows you to upload in Video libraries or use a folder in the file system.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    27 May 2010
    Link to this post
    Ok thanks a lot !That what I thought too.

    However, when deriving from SitefinityImage, the only available libraries seem to be those containing images. I tried to poke around using Reflector, but I can't find what causes this behavior.

    I guess I need to override the ImageUrl property and decorate with an attribute, but I can't find which one. Do you have any pointers ?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 May 2010
    Link to this post
    Hi Lucas,

    SitefinityImage inherits from System.Web.UI.WebControls.Image. We only have a helper method that resolve the dynamic url and there is a small changes in the Render method related to the url resolving. Since this is an image control it purpose is to work only with images.

    You could crate a custom control which supports three modes - Images, Video and Flash. You could expose three public properties with selectors to Image, Video and Flash/Custom library. Depending on which item you want to show you will render an Image, Video or Flash object.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    28 May 2010
    Link to this post
    Thanks.

    Silly question: is there a codebehind file somewhere for "ImageEditorDialog.ascx" ?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    28 May 2010
    Link to this post
    Hello Lucas,

    No, this is just a template for the built in class.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    28 May 2010
    Link to this post
    Hi Ivan,

    Thanks for your patience :)

    I find this template great, and I was hopping to be able to extend its functionalities. I understand the concept of templates, but I don't grasp how it is instantiated (and moreover how sitefinity handles the postback to save the object.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    28 May 2010
    Link to this post
    Hello Lucas,

    The class ImageEditorDolog uses ITemplate Interface that handles the template and how the control is populated with with child controls. There is a method ITemplate.InstantiateIn that defines the control object that child controls and templates belong to. We use GenericContainer<T> to get all controls from the template. There are events that are used to handle the post back during selection or uploading. Also, there is a method LoadControlState which loads the state of the control after postback.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
8 posts, 0 answered