I want to access (and then modify) the properties for the image field(s) in Sitecore (esp. interested in ‘Dimensions’ and ‘Keep Ratio’ check box) via a code-behind file (blah.ascx.cs).
[This to ensure that all the images have a consistent size, when displayed in the sublayouts (irrespective of the original size)]
I know these properties can be added manually, but for the case where content authors “forget” to add the dimensions for image(s), I don’t want my sublayouts to screw up. Hence, I need a check for that.
Is there a way to access and then modify these properties via code?
Here is an image that shows exactly what I want to access and modify via code:

If you’re using an
<asp:Image ... />and binding theImageUrlvia C#, you can access theImageFieldin C# and get the properties, like so:If you’re using a
<sc:Image ... />renderer or a regular<sc:FieldRenderer ... />I would recommend you use<sc:FieldRenderer ... />as the image parameters only work on that, as documented here.Here’s a sample snippet: