Image thumbnail auto-generation for existing images
I want to auto-generate image thumbnail for all images in Meda tab. I set a width value (e.g. 200) for the Upload data type. However, this only applies to image added after the new setting. Existing images that were added before the new value don't have thumbnail with the specified width.
How can I generate the image thumbnails with the specified with for all the exsting images.
What version of Umbraco are you using? If I remember correctly one is not able to alter the value of the preview width in newer versions of Umbraco? But I do remember that it was possible in older versions when the more advanced media picker was a 3rd party package.
Is the thumbnail generated after the media item is resaved? You could write some custom code which resaved all the images. Something like this (with the old API):
public class MediaExample
{
protected static umbraco.DataLayer.ISqlHelper SqlHelper
{
get { return umbraco.BusinessLogic.Application.SqlHelper; }
}
public static void SaveMedia()
{
string sql = @"
select un.id
from umbracoNode un
where un.nodeObjectType = @type";
//Get all the media items.
using (IRecordsReader dr = SqlHelper.ExecuteReader(sql, SqlHelper.CreateParameter("@type", Media._objectType)))
{
//Loop trough all the media items.
while (dr.Read())
{
//Get the id of a media item.
int mediaId = dr.GetInt("id");
//Call the save method so all save events can be fired again.
Media media = new Media(mediaId);
media.Save();
media.XmlGenerate(new XmlDocument());
}
}
}
}
Just call MediaExample.SaveMedia(); somewhere to resave all media.
Image thumbnail auto-generation for existing images
I want to auto-generate image thumbnail for all images in Meda tab. I set a width value (e.g. 200) for the Upload data type. However, this only applies to image added after the new setting. Existing images that were added before the new value don't have thumbnail with the specified width.
How can I generate the image thumbnails with the specified with for all the exsting images.
Hi Pingpong
What version of Umbraco are you using? If I remember correctly one is not able to alter the value of the preview width in newer versions of Umbraco? But I do remember that it was possible in older versions when the more advanced media picker was a 3rd party package.
Looking forward to hearing from you.
Cheers,
Jan
Hey,
Not sure it's possible without coding as these thumbnails are created when you upload or save the image.
Why don't you just use imagegen to create the thumbnails on the fly like
/imagegen.ashx?image=/media/image.jpg&width=200
Rich
Hello,
Is the thumbnail generated after the media item is resaved? You could write some custom code which resaved all the images. Something like this (with the old API):
Just call MediaExample.SaveMedia(); somewhere to resave all media.
Jeroen
And if you only need cropped thumbnails you could have a look at the DAMP Gallery: http://24days.in/umbraco/2012/damp-gallery/
Jeroen
is working on a reply...