Image resize

Posted by Community Admin on 04-Aug-2018 02:27

Image resize

All Replies

Posted by Community Admin on 26-Jun-2013 00:00

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!

Posted by Community Admin on 26-Jun-2013 00:00

This article is great for setting up custom thumbnail sizes. I've used it a number of times.

Posted by Community Admin on 26-Jun-2013 00:00

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...

Posted by Community Admin on 26-Jun-2013 00:00

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

Posted by Community Admin on 26-Jun-2013 00:00

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 :\

Posted by Community Admin on 26-Jun-2013 00:00

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.

Posted by Community Admin on 26-Jun-2013 00:00

Hmm, is that possible when using an  'ImageAssetsField' element? Currently in my template I have: <sf:ImageAssetsField runat="server" DataFieldName="Image" IsThumbnail="False" />

Posted by Community Admin on 26-Jun-2013 00:00

No, not directly.  

Posted by Community Admin on 26-Jun-2013 00:00

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.

Posted by Community Admin on 26-Jun-2013 00:00

There is also this for just front end use: <img src="<%# Eval("MediaUrl")%>&size=250" />

Posted by Community Admin on 26-Jun-2013 00:00

There is this for front end use: <img src="<%# Eval("MediaUrl")%>&size=150" />

Posted by Community Admin on 28-Jun-2013 00:00

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

This thread is closed