1

I was wondering whether there is a way to suppress rendering the width and height attributes when using the Image component from @sitecore-jss/sitecore-jss-react? Or under the hood, it basically uses the standard Sitecore Field Renderer so not really? It ends up distorting our design.

At the moment we are using this as a workaround:

{isExperienceEditorActive() ? (
    <Image media={fields.Image} />
) : (
    <img src={fields.Image.value.src} alt={fields.Image.value.alt}></img>
)}

— but that means it still looks distorted in Experience Editor.

I suppose the other option would be to try to strip them out from DOM but I think that might cause flickering & generally seems like not a very elegant solution.

1
  • 1
    Just saw this too. It's frustrating as it's not the same way MVC rendering works. There you have the choice of leaving the width/height empty and it's not rendered. For now I'm getting round it by using CSS. width: unset; height: unset; Jul 13 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.