我的amp-img代码不起作用。始终显示来自属性src的图像。谁能告诉我我错了吗?
<amp-img src="/v9/public/fileadmin/user_upload/TEST.jpg"
width="1200"
height="450"
layout="responsive"
alt="alt-text"
title="title-text"
srcset="/v9/public/fileadmin/user_upload/TEST.jpg 998w,
/v9/public/fileadmin/_processed_/c/b/csm_TEST_ce1818a3d8.jpg 778w,
/v9/public/fileadmin/_processed_/c/b/csm_TEST_1eee503f4e.jpg 450w"
sizes="100vw"></amp-img>
我找到了解决方法。但是srcset会更好。
<amp-img alt="xyz"
amp-fx="parallax"
data-parallax-factor="1.2"
media="(min-width: 832px)"
width="1200"
height="450"
layout="responsive"
src="<f:uri.image image='{file}' cropVariant='desktop' />"></amp-img>
<amp-img alt="xyz"
amp-fx="parallax"
data-parallax-factor="1.2"
media="(min-width: 451px) and (max-width: 831px)"
width="767"
height="450"
layout="responsive"
src="<f:uri.image image='{file}' cropVariant='tablet' />"></amp-img>
<amp-img alt="xyz"
amp-fx="parallax"
data-parallax-factor="1.2"
media="(min-width: 0px) and (max-width: 450px)"
width="350"
height="450"
layout="responsive"
src="<f:uri.image image='{file}' cropVariant='mobile' />"></amp-img>