I can't seem to get the DynamicMedia thumbnail crops genereted via. the Upload data type. I can see all my thumbnails in the media folder but can't access them in the code. Here is my code (Umbraco 4.7):
public static void GetMediaById(int id)
{
dynamic media = new DynamicMedia(id);
var name = media.name;
var file = media.umbracoFile;
var ext = media.umbracoExtension;
int width = 0;
int height = 0;
try
{
int.TryParse(media.umbracoWidth, out width);
int.TryParse(media.umbracoHeight, out height);
}
catch
{
// Ignore this as some file types won't have a width or height.
}
// Get thumbnail crops - how?
}
When umbraco saves a media file it saves its withd and height and also generates a thumbnail for you (assuming it's an image). The thumbnail has the same filename as the original image, is in the same folder, but has "_thumb" appended to it.
If the umbracoFile property were "myphoto.jpg" the thumbnail of it would be "myphoto_thumb.jpg"
You can make multipel thumbnail sizes automatically with Umbraco (go to the developer section, expand the 'datatypes' section, and click the 'upload' data type... then add a list of sizes such as 60;111;482). Or, use ImageGen which has many more options. There's also the cropper datatype built into umbraco that is very handy.
But I suspect you mean you want the thumbnail files to be listed in the media object itself but they aren't.
Umbraco DynamicMedia thumbnail crops
I can't seem to get the DynamicMedia thumbnail crops genereted via. the Upload data type. I can see all my thumbnails in the media folder but can't access them in the code. Here is my code (Umbraco 4.7):
When umbraco saves a media file it saves its withd and height and also generates a thumbnail for you (assuming it's an image). The thumbnail has the same filename as the original image, is in the same folder, but has "_thumb" appended to it.
If the umbracoFile property were "myphoto.jpg" the thumbnail of it would be "myphoto_thumb.jpg"
Make sense?
cheers,
doug.
Thank you for the reply. This makes sense. I was hoping the object would have crops so I wouldn't have to hardcode image sizes like this:
myphoto_thumb60.jpg
myphoto_thumb111.jpg
myphoto_thumb482.jpg
You can make multipel thumbnail sizes automatically with Umbraco (go to the developer section, expand the 'datatypes' section, and click the 'upload' data type... then add a list of sizes such as 60;111;482). Or, use ImageGen which has many more options. There's also the cropper datatype built into umbraco that is very handy.
But I suspect you mean you want the thumbnail files to be listed in the media object itself but they aren't.
cheers,
doug.
is working on a reply...