WordPress already does this, 至少有两种方式
例如,以下是<img>
本地测试安装上标准库块的标记:
<img src="http://one.wordpress.test/wp-content/uploads/2020/03/80694475_10220097889178767_6336534537924771840_n.jpg" alt="" data-id="15" data-full-url="http://one.wordpress.test/wp-content/uploads/2020/03/80694475_10220097889178767_6336534537924771840_n.jpg" data-link="http://one.wordpress.test/?attachment_id=15" class="wp-image-15" srcset="http://one.wordpress.test/wp-content/uploads/2020/03/80694475_10220097889178767_6336534537924771840_n.jpg 750w, http://one.wordpress.test/wp-content/uploads/2020/03/80694475_10220097889178767_6336534537924771840_n-300x229.jpg 300w" sizes="(max-width: 750px) 100vw, 750px">
<有一个数据属性:
data-id="15"