I have a string that contains text and some html elements. I want to find the img elements that have the class size-thumbnail and add some html around it.
For example, From:
<img class="size-thumbnail wp-image-279 alignleft" title="fellaisworkinghard" src="workinghard-150x150.png" alt="" height="150" width="150">
To:
<div style="width:150px;" class="article-image">
<img class="size-thumbnail wp-image-279 alignleft" title="fellaisworkinghard" src="workinghard-150x150.png" alt="" height="150" width="150">
<span style="width:150px;" class="article-image-content">BLABLA</span>
</div>
The widths on the div and span elements are taken from the width of the image. Whats the best way of doing this, and how?
I thought of using regex to get the height but I don't know how to add everything else on the right position.