Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7086311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:32:02+00:00 2026-05-28T07:32:02+00:00

I want to access (and then modify) the properties for the image field (s)

  • 0

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:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:32:02+00:00Added an answer on May 28, 2026 at 7:32 am

    If you’re using an <asp:Image ... /> and binding the ImageUrl via C#, you can access the ImageField in C# and get the properties, like so:

    Sitecore.Data.Fields.ImageField field = item.Fields["My Image Field"];
    // you can now access:
    //   field.Width
    //   field.Height etc...
    

    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:

    <sc:FieldRenderer FieldName="My Image Field" Parameters="w=100&h=200&as=1" runat="server" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to update a Object in another thread, and then access it in
In WPF, I want to use a pixel shader to modify a composite image
I have a data structure that I want to access / modify in different
I want to access camera to record video to upload, but have come across
I want to access the following path on Ubuntu in my python code: ~/.mozilla/firefox/dh4ytbdj.default/bookmarkbackups
I want to Access Information of Builds of Team Projects to use them in
I want to access java script's return value , which in is in a
I want to access text-shadow property just like we access padding property. Means ,
I want to access a static variable from a static method: #!/usr/bin/env python class
I want to access the session variable which I declared in the another php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.