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

Image resize

12 posts, 1 answered
  1. Rico
    Rico avatar
    88 posts
    Registered:
    30 Aug 2012
    26 Jun 2013
    Link to this post
    Hello,
    Is there a way to change/configure what the available options are for resizing an image during upload (to an album)? Attached is a screenshot of the available sizes -- however, none of these sizes work for me -- I would like to configure my own. (I want my images to be 150 pixels wide for instance). How would I go about doing this?

    Thanks!
  2. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    26 Jun 2013 in reply to Rico
    Link to this post
    This article is great for setting up custom thumbnail sizes. I've used it a number of times.
  3. Rico
    Rico avatar
    88 posts
    Registered:
    30 Aug 2012
    26 Jun 2013 in reply to Jonathan
    Link to this post
    Hi Jonathan,

    Yes thanks -- I did come across that article as well to follow. I was 'hoping' that there would be something for easier/simpler to do though -- as the 'default' LOV is populated by values (pixel width values) -- I was hoping this LOV's values were stored simply (in a config file or something) so that they could be easily modified and thus eliminate the need to add in customized code handling...
  4. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    26 Jun 2013 in reply to Rico
    Link to this post
    You could enable Allow dynamic resizing of images in Settings >> Advanced >> Libraries >> Images (image attached)

    this allows you to page image.png?size=150 and dynamicly resizes the image to a width of 150px
    Answered
  5. Rico
    Rico avatar
    88 posts
    Registered:
    30 Aug 2012
    26 Jun 2013 in reply to Jonathan
    Link to this post
    Hmm, yes that could work; however it's not ideal (I'm currently in the process of importing in a large amount of images (200+) into my library/album -- manually resizing them would be a pain :\
  6. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    26 Jun 2013 in reply to Rico
    Link to this post
    It's manually re-sizing it Dynamically.  So wherever you are using the image you add the Query string to it and it is re-sized at runtime. <img src="/images/image.png?size=150" /> You would import your images as normal then use whatever size you need wherever.
  7. Rico
    Rico avatar
    88 posts
    Registered:
    30 Aug 2012
    26 Jun 2013 in reply to Jonathan
    Link to this post
    Hmm, is that possible when using an  'ImageAssetsField' element? Currently in my template I have: <sf:ImageAssetsField runat="server" DataFieldName="Image" IsThumbnail="False" />
  8. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    26 Jun 2013 in reply to Rico
    Link to this post
    No, not directly.  
  9. Rico
    Rico avatar
    88 posts
    Registered:
    30 Aug 2012
    26 Jun 2013 in reply to Jonathan
    Link to this post
    Thanks for the brainstorming session -- got it to work:

    Front end code:
    <img src="<%# GetImageUrl(Container.DataItem) %>" alt="" />

    Back end code:

    protected string GetImageUrl(object item)

    {

    var retval = string.Empty;

    // ensure correct item type

    var product = item as DynamicContent;

    if (product == null) return retval;

    // retrieve the Screenshot value and extract the first (and only) item

    var contentLinks = (ContentLink[])product.GetValue("Image");

    ContentLink imageContentLink = contentLinks.FirstOrDefault();

    if (imageContentLink != null)

    {

    // retrieve the image using the extracted items Id

    LibrariesManager libraryManager = LibrariesManager.GetManager();

    var image = libraryManager.GetImage(imageContentLink.ChildItemId);

    if (image == null) return retval;

    // return the image url to the template

    retval = image.Url;

    //dynamic resize

    retval += "&size=150";

    }

    return retval;

    }

    I'll do a bit more fine-tunning on it, but the jist of it works.

    Cheers.

  10. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    26 Jun 2013
    Link to this post
    There is also this for just front end use: <img src="<%# Eval("MediaUrl")%>&size=250" />
  11. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    26 Jun 2013 in reply to Rico
    Link to this post
    There is this for front end use: <img src="<%# Eval("MediaUrl")%>&size=150" />
  12. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    28 Jun 2013
    Link to this post
    Hello guys,

    There has already been a discussion about this functionality about how to add custom sizes for image uploads here

    Regards,
    Pavel Benov
    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 Public Issue Tracking system and vote to affect the priority of the items
12 posts, 1 answered