I have a Tag Helper for rendering responsive images in Umbraco 11. I'd like to be able to read the value for maximum image width and height, which I can see is set as 5000 by default in both the appsettings-schema.json and /umbraco/config/appsettings-schema.json files:
"Resize": {
"properties": {
"MaxWidth": {
"description": "Value for the maximum resize width",
"type": "integer",
"default": 5000
},
"MaxHeight": {
"description": "Value for the maximum resize height",
"type": "integer",
"default": 5000
}
}
}
I've seen the documentation on how to read configuration data in code but I'm not sure what to do to be able to read the image size values as they're set in the appsettings-schema file rather than the appsettings file. Is it just a case of replicating that part of the json object so it's in the main appsettings.json file, from where it will be readable?
(As a related question, out of curiosity, how would you override these values - would do you that in the appsettings-schema file or the appsettings file?)
Read value from app settings in custom class
Hi,
I have a Tag Helper for rendering responsive images in Umbraco 11. I'd like to be able to read the value for maximum image width and height, which I can see is set as 5000 by default in both the
appsettings-schema.json
and/umbraco/config/appsettings-schema.json
files:I've seen the documentation on how to read configuration data in code but I'm not sure what to do to be able to read the image size values as they're set in the appsettings-schema file rather than the appsettings file. Is it just a case of replicating that part of the json object so it's in the main
appsettings.json
file, from where it will be readable?(As a related question, out of curiosity, how would you override these values - would do you that in the appsettings-schema file or the appsettings file?)
Thanks for any clarification on this!
Think I figured it out! 😅
To override the values, it would be a case of modifying the appsettings.json file, like this:
Then to read those values in code, you'd follow the docs but instead of using
GlobalSettings
, useImagingSettings
.is working on a reply...