On my site, each post starts with an image:
<img src="sample.jpg" alt="sample alt" />
and what I'm looking for is to change all image entries to:
<img data-src="sample.jpg" alt="sample alt" />
So basically I want to either:
- Append/prefix
src
withdata-
or
- Replace/substitute
src
withdata-src
I've looked at .replace()
.replaceWith()
.before()
.insertBefore()
and none of them did what I wanted.
A bit of info on why I want to do this. I want to implement unveil.js (lazyload) and one of the requirements is to include the actual image source in a "data-src" attribute. I don't want to mix html with markdown, hence this question.