Vulnerability in EPiServer.Forms
Is there a way to get the image dimensions from an uploaded image? The property is of type ContentReference with ImageFile as UIHint.
I don't have the code infront of me now. But first you need to load the MediaData object from the ContentReference you have then load the binary data into an Image, something like this:
var mediaData = GetMediaDataFromContentReferenceSomehow(yourContentReference);
using (var image = Image.FromStream(mediaData.BinaryData.OpenRead()))
var height = image.Height;
var width = image.Width;
This might be an expensive operation to do, so keep that in mind. Cache the result or add dimension properties to you content data model and set the values after the image is uploaded by listening to content events. That way you don't have to load the binary data every time and the data will be cached.
That worked, thanks! :)