Shrinking images in editor with HTML height attribute

The option to shrink images in the editor doesn’t work as expected when the HTML height attribute is used with img elements. If the option is unticked, the value of the height attribute is respect. If it’s ticked, the default width and height (125px?) are applied. It doesn’t appear that the data-editor-shrink attribute is consistently set or modified in these cases either. Is there any way to force the height attribute to be honoured in all circumstances?

1 Like

As an alternative you can use this addon instead:
https://ankiweb.net/shared/info/181103283
It works great for me.

1 Like

Probably relevant PR that was merged about a month ago:

Exactly this scenario is considered there. Thank you.

@dae @kleinerpirat Is there any reason why img elements with the height and/or width attribute set can’t be left alone when shrinking is enabled?

The change was made because they were left alone, and it was distorting the aspect ratio of the images. To support your use case and avoid introducing that issue again, some other way of preserving the aspect ratio would be required.

Was the distortion of the aspect ratio not a result of the manipulation of one of the attributes when only the other was set? If so, can’t it be assumed that if at least one of height or width is set for a given img element, shrinking should not apply? I don’t know how images were handled before this change and what caused the aspect ratio distortion, so this is well-intentioned speculation and curiosity.

I fear that would lead to confused users complaining that the shrinking feature isn’t working, because their images happen to include width/height tags. They may not have added them themselves, as they may be using shared decks or have used add-ons that did so in the past.

Could we perhaps have a setting, then, and make the logic more transparent?

I’d rather it do the right thing automatically than require an extra setting. Did you have any thoughts on how to tackle this @kleinerpirat?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.