Do you have the IIS virtual directory set up for the thumbnails? The setup should look like that, a virtual directory under /EPiServerCommunity/Modules/ImageGallery/Thumbnails or something like that which points to the actual thumbnails storage folder in the community file folder.
I do. Some of the thumbnails actually work, while others do not (and are missing from the file system).
My theory was therefore that some of these thumbsnails were created during the testing phase on other machines. So I'd like to force the system to re-create these if possible, since they exist in db but not on disk? The originals are all there from what I can see.
// Kristian
I don't think it's easy. I had this problem in a site a few years ago, running community 3.0/3.1. In the production environment actually. For some reason some images disappeared now and then (ill-timed app-pool recycles?). The worst thing about it is that you can't administer the users because the portrait thumbnail is visible in the user administration which causes it to crash if the file is missing...
What I did back then was to write a scheduled job which simply checked all thumbnails if they existed on disk. If they didn't, they were replaced by a dummy image and then the Image object was removed (if you try to do that without first placing the dummy file - yes, there will be an exception...). I suppose you could do the same, but grab the original and re-upload it as a new Image object which would also create new thumbnails.
I don't have any code left and it feels like there might be a simpler way too.
Thank you Magnus for your assistance. I much appreciate it.
What I ended up doing was that I used Reflection to look inside the CreateThumbnail method of ImageGalleryFactory (EPiServer.Community.ImageGallery.Data). The first half creates db-entries, which I already had, so I skipped to the second part.
Thumbnail thumbnail = null;
System.Drawing.Size size = GetImageSize(imageSize);
thumbnail = image.GetThumbnail(size.Width, size.Height, ThumbnailFormat.ReduceAndCrop);
// Thumbnail path
string path = System.Web.Hosting.HostingEnvironment.MapPath(ImageGalleryModule.GetVirtualThumbnailPath(image.ImageGallery.ID));
// Thumbnail filename
string fileName = Path.Combine(path, string.Concat(new object[] { image.ID, "_", Convert.ToString(thumbnail.ID), ImageGalleryModule.ImageExtension }));
// If the thumbnail exists, just return it
if (File.Exists(fileName))
{
return new UrlBuilder(thumbnail.Url).Uri;
}
else
{
// Otherwise, use the CreateThumbnail logic to "re-create" it
System.Drawing.Image original =
System.Drawing.Image.FromFile(Path.Combine(ImageGalleryModule.GetAbsoluteImageGalleryPath(image.ImageGallery.ID), image.ID + ImageGalleryModule.ImageExtension));
if ((original != null) && (path != null))
{
Bitmap bitmap = null;
if ((image.Width == size.Width) && (image.Height == size.Height))
{
bitmap = new Bitmap(original);
}
else
{
bitmap = GetReducedAndCroppedImage(original, size.Width, size.Height, Color.Transparent);
}
original.Dispose();
if (ImageGalleryModule.ImageFormat == System.Drawing.Imaging.ImageFormat.Jpeg)
{
SaveJpegWithCompressionSetting(bitmap, fileName, ImageGalleryModule.ImageQuality);
}
else
{
bitmap.Save(fileName, ImageGalleryModule.ImageFormat);
}
bitmap.Dispose();
}
else
{
thumbnail = null;
}
}
if (thumbnail != null)
{
return new UrlBuilder(thumbnail.Url).Uri;
}
All this inside the GetThumbnailUri method that was being used by my startpage box to fetch member images. (Some private methods from inside ImageGalleryFactory were also copied out, but I've excluded these for brevity.)
This works like a charm and I am a happy man :)
Hello friends
Having some issues with thumbnails trying to integrate an existing Relate-site into an existing EPiServer site.
I've done this:
1. I've copied all the Common/Community tables into the standard EPiServer-database on a local system.
2. Made sure everything ran fine, but without Relate-content such as user images since the VPP folders of the Relate-site were pretty huge.
3. After I was happy with functionality I deployed to the live system, where I had also copied the Relate-site's VPP folder into the EPi one.
Everything is running fine, except the thumbsnails of the users are all broken. When I go to their profile pages, the full size pictures appear fine but when I try to display their tiny counterparts in a box on the start page they all appear as broken links. Checking the VPP folder also confirms that the files are nowhere to found.
My questions is then, is there anyway to "clear" all the thumbnails and force the system to recreate these files? Can I just wipe the data from the thumbnail table in the database or will that wreak even more havoc?
Would be grateful for some assistance with this matter. I'm running EPi6 and Relate1.0.
// Kristian