Reputation: 33
Accelerated Mobile Pages (AMP) Project
Original
<div class="thumbnail">
<img src="MyImage.jpg" alt="an image"/>
</div>
Result
<div class="thumbnail">
<amp-img src="MyImage.jpg" width="1080" height="610" layout="responsive" alt="an image"></amp-img>
</div>
How to do it with jQuery ?
Upvotes: 1
Views: 1588
Reputation: 9060
Use .replaceWith()
API to replace the content :
$('.thumbnail').find('img').replaceWith(function () {
return '<amp-img src="'+this.src+'" width="1080" height="610" layout="responsive" alt="'+this.alt+'"></amp-img>'
});
Upvotes: 1