How to get image variants dynamically
I am creating one banner widget in which i am uploading the image and i have defined one widget property which is one dropdown showing all image variants. Based on that selection i want to render widget.
Now in the dropdown widget property currently i have hardcoded the options as follow:
[DropDownComponent(Label = "Select Image Variants Type",
Order = 1,
Options = $"Default;Default" + $
"\nImageVariant1;ImageVariant1"
+
$"\nImageVariant2;ImageVariant2" + $
"\nImageVariant3;ImageVariant3"
+ $"\nTest;Test",\
OptionsValueSeparator = ";",
Placeholder = "Select ImageVariants")]
public string ImageVariants { get; set; } = "Default";
Now in future it can be changed so i wanted to know if there is way to dynamically retrieve the image variants
Environment
Xperience by Kentico version: [30.5.3]
.NET version: [8]
Answers
Take a look at CMS.ContentEngine.StandardMediaDimensionsInfo
.
You can also query this data in the database if you want to verify it's what you're looking for.
SELET *
FROM CMS_StandardMediaDimensions
You can follow the docs to see how to query for this data using IInfoProvider<T>.
If you want to populate a drop down in component properties with this data, take a look at our documentation for Configure editing component state.
To answer this question, you have to login first.