+1-888-365-2779
Try Now
More in this section

Forums / Designing with Sitefinity / Image size in generic content

Image size in generic content

4 posts, 0 answered
  1. Elizabeth
    Elizabeth avatar
    83 posts
    Registered:
    23 Mar 2005
    03 Aug 2009
    Link to this post
    If an image is uploaded when a generic content control is being edited, it is automatically resized. What sets the new size for the image and can we change what the height/width should be?

    If an image is added to generic content control that has already been added to the library, then it is not resized. Why does this behave differently?
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    06 Aug 2009
    Link to this post
    Hello Elizabeth Munsey,

    You are right, it behaves differently.

    The difference come from the fact that we are resizing (resizing only, rather than resize and recompress) the image when it is inserted through the tool. This was an User experience decision. 
    You can change this behavior by altering the following file:

    Sitefinity\Admin\ControlTemplates\News\Dialogs\ButtonSelector.ascx and the lines:

    ... 
            element.src = sender.argument.src + '?width=300&height=300&decreaseOnly=true'; 
                        else if (typeof (element.value) != 'undefined' && element.value != null) { 
    ... 

    Let me know if you have any other questions.
     
    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. Gökhan Yalçın
    Gökhan Yalçın avatar
    21 posts
    Registered:
    26 Nov 2009
    23 Feb 2010
    Link to this post
    Hi ,
    This solution does not work for me, I did what you explain but it did not work . Besides I need to fix this in news module .
    Is there anything I am missing here ?

    Thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Feb 2010
    Link to this post
    Hello Gökhan Yalçın,

    You can change the value of the query string using  Reflection and this solution will work in full trust only. The QueryString is hardcoded and cannot be changed easily due to the privacy of LibraryImageDialogContainer.


    1.Create a custom class in App_Code folder:


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Cms.Engine;
    using Telerik.Libraries;
    using Telerik.Cms.Web;
    using Telerik.Libraries.WebControls;
    using Telerik.Cms.Web.UI;
    using Telerik.Utilities.Reflection;
    using System.Web.UI.WebControls;
      
    namespace Sitefinity.Samples
    {
      
        /// <summary>
        /// Summary description for CustomImageEditorDialog
        /// </summary>
        public class CustomImageEditorDialog : Telerik.Libraries.WebControls.ImageEditorDialog
        {
            public CustomImageEditorDialog()
            {
      
            }
      
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
      
                Guid itemID = (Guid)ReflectionHelper.GetPrivateField(this, typeof(ImageEditorDialog), "itemID");
                if (itemID != Guid.Empty)
                {
                    LibraryManager Manager = new LibraryManager();
                    IContent content = Manager.GetContent(itemID);
                    string name = (string)content.GetMetaData("Name");
      
                    GenericContainer<ImageEditorDialog> container = (GenericContainer<ImageEditorDialog>)ReflectionHelper.GetPrivateField(this, typeof(ImageEditorDialog), "container");
                    if (container != null)
                    {
                        Image uploadedImage = container.GetControl<Image>("uploadedImage", false);
                        if (uploadedImage != null)
                        {
                            uploadedImage.ImageUrl = content.UrlWithExtension + "?width=200&height=200&decreaseOnly=true";
                            uploadedImage.Attributes.Add(LinkParser.InternalLinkAttrebuteName, String.Concat("[", content.ProviderName, "]", content.ID));
                        }
                    }
                }
            }
      
        }
    }


    2. Remove the declaration of ImageEditorDialog from ~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx

    3. Register tag prefix for our custom control and declare it.

    <%@ Register TagPrefix="cc1" Assembly="App_Code" Namespace="Sitefinity.Samples" %>
     <cc1:CustomImageEditorDialog runat="server" DisplayMode="Images" ></cc1:CustomImageEditorDialog>


    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.
Register for webinar
4 posts, 0 answered