将<img/>转换为<img-amp>

时间:2018-02-12 18:40:46

标签: image amp-html accelerated-mobile-page amp-img

我正在研究nodejs&amp; MongoDB的。 当我放置这个代码; <%- postContent %>,它呈现如下格式:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
<img title="Image Title" class="alignnone wp-image-9453 size-full" src="https://example.com/images/2017/03/image-name-1.jpg" alt="image alt here" width="847" height="507" srcset="https://example.com/images/2017/03/image-name-1.jpg 847w, https://example.com/images/2017/03/image-name-1-300x180.jpg 300w, https://example.com/images/2017/03/image-name-1-768x460.jpg 768w, https://example.com/images/2017/03/image-name-1-825x493.jpg 825w, https://example.com/images/2017/03/image-name-1-410x246.jpg 410w, https://example.com/images/2017/03/image-name-1-150x90.jpg 150w" sizes="(max-width: 847px) 100vw, 847px">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>

现在,我的疑问是;如何将<img>转换为<amp-img>

1 个答案:

答案 0 :(得分:-2)

无法转换。你必须用amp-img元素替换img元素。

你必须使用amp-img属性src和布局,宽度和高度相对于布局。