1

I'm on Sitecore 8.2 with Synthesis 8.2.6. I'm currently using the provided helpers Field.RenderedValue and Field.Url.

I'd like to request the images with specific size parameters depending on the control being rendered.
Do I need to create my own render of this, or is there a way to impact what args are used for the media Url?

1 Answer 1

2

Synthesis has an extension method for ImageFields called RenderDpiAware (link) that allows you to specify a bunch of sizes to be used in a CSS source set.

Additionally, the Render() extension method (link) on ImageFields has the ability to set a max width and max height. In a razor view, it would look like:

@Model.YourImageField.Render(maxWidth: 100, maxHeight: 100) (both fields are optional, so you don't need to specify both).

2
  • I hadn't yet included the Synthesis.Mvc NuGet package, which I needed so I could have the .Render() helper. Jul 12, 2019 at 16:34
  • Note: because were using maxHeight and maxWidth, scaling an image up will not happen Jul 12, 2019 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.