How do I automatically put width and height in the img field in CKEditor?

I'm making my site AMP capable. I'm struggling in converting <img> to <amp-img>.

I already managed to convert <img> to <amp-img> by making a custom twig filter but I have a problem filling out width and height attribute of the image, because in the Drupal CMS, when you upload an image in the CKEditor field, it doesn't populate the width and height attribute.

In the Allowed HTML tags, I already added this:

<img src width height alt data-entity-type data-entity-uuid data-align data-caption>

How can I automatically add width and height attribute to the image when I upload image to the CKEditor?

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.