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

Forums / Developing with Sitefinity / Image width/height setting while creating image in a album

Image width/height setting while creating image in a album

3 posts, 0 answered
  1. kamii47
    kamii47 avatar
    71 posts
    Registered:
    02 Mar 2007
    24 Apr 2014
    Link to this post

     I am using following code to upload an image in a album. what i wan't is that the width and height of the image setting should be in my control. I have tried newVid.Width = mywidth; and newVid.Height = myheight but image remain same. any idea what change i do in following code to achieve it

    Telerik.Sitefinity.Libraries.Model.Album album = App.WorkWith().Albums().Where(i => i.Title == albumName).Get().FirstOrDefault() ??
                                                                     App.WorkWith().Albums().Get().FirstOrDefault();
     
                    LibrariesManager libManager = LibrariesManager.GetManager();
                    libManager.Provider.SuppressSecurityChecks = true;
                    Telerik.Sitefinity.Libraries.Model.Image newVid = libManager.CreateImage();
                    newVid.Parent = libManager.GetAlbum(album.Id);
                    //newVid.Title = imageTitle;
                    Guid imageId = newVid.Id;
                    newVid.Title = imageTitle;
                    newVid.DateCreated = DateTime.UtcNow;
                    newVid.PublicationDate = DateTime.UtcNow;
                    newVid.LastModified = DateTime.UtcNow;
                   
     
                    newVid.Urls.Clear();
                    //newVid.UrlName = Regex.Replace(imageTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); ;
                    newVid.UrlName = Regex.Replace(imageId.ToString(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
                    libManager.Upload(newVid, imageStream, imageExtension);
                    libManager.RecompileItemUrls(newVid);
                    libManager.Lifecycle.Publish(newVid);
                    libManager.SaveChanges();

  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    28 Apr 2014
    Link to this post
    Hi Kamran,

    You could try to resize the image in the Stream before uploading it.

    I hope the examples here and here are helpful.

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. kamii47
    kamii47 avatar
    71 posts
    Registered:
    02 Mar 2007
    30 Apr 2014 in reply to Svetoslav Manchev
    Link to this post

    Thanks Svetoslav Manchev,

    I were looking for the thing within sitefinity. Now will try to resize file prior to saving

3 posts, 0 answered