Accessing the Width and Height attributes of images uploaded with Multiple Media Picker
I wish to know how to access the width and height attributes of images uploaded using the Multiple Media Picker. The images that are being uploaded are going to be used as part of a Carousel but to ensure that the look and feel of this element does not break through the use of different sized images I am going to ensure that images that do not match the width and height requirements of the Carousel are not output as part of the collection.
I'm currently doing the following:
var bannerImagesList = Model.Content.GetPropertyValue<string>("bannerImages").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var bannerImagesCollection = Umbraco.TypedMedia(bannerImagesList).Where(x => x != null);
I then have a foreach loop where I output each image:
I can access the ID of the image just fine using @bannerImage.Id as this is a property but how to I gain access to the attribute s of the image itself and not the properties of the object?
I am using the standard Image media type as I have not declared any of my own Media Types.
How would I then go about checking to see if my image widths match what I need? I've tried the following:
Accessing the Width and Height attributes of images uploaded with Multiple Media Picker
I wish to know how to access the width and height attributes of images uploaded using the Multiple Media Picker. The images that are being uploaded are going to be used as part of a Carousel but to ensure that the look and feel of this element does not break through the use of different sized images I am going to ensure that images that do not match the width and height requirements of the Carousel are not output as part of the collection.
I'm currently doing the following:
I then have a foreach loop where I output each image:
I can access the ID of the image just fine using @bannerImage.Id as this is a property but how to I gain access to the attribute s of the image itself and not the properties of the object?
Hi Jason,
Are you using the standard "Image" media type or one of your own?
If you are using the standard "Image" media type, you can do this:
Jeavon
Hi Jeavon,
I am using the standard Image media type as I have not declared any of my own Media Types. How would I then go about checking to see if my image widths match what I need? I've tried the following:
But in VisualStudio is states that the == operator cannot be used on types 'int' or 'Object'.
Jason
Nevermind. I think I've sussed it now.
That's the one :-)
is working on a reply...