Is there a way to replace img tag with div tag like below?
Original html:
<div class="article">
  <img src="/images/img-1.jpg" alt="alt for image">
</div>
Replaced html:
<div class="article">
 <div style="background: transparent url(/images/img-1.jpg) no-repeat;
 background-position: center center; background-size: cover; width: 566px; 
 height: 576px;">alt for image</div>
</div>
(Optional) Also is it possible to use the width and height from the parent div i.e. article class in my example instead of defining fixed width: 566px; height: 576px;?
If it's possible, I want to use the str_replace function.
str_replace('?????', '?????', $article);
Edit:
There may be multiple elements with class article and there may be other elements inside article class div and from which I need to change img to div.
Edit2:
I was meaning as if I may have any content inside article div and just want to replace the img with div.
I may have:
<div class="article">
  <h1>heading</h1>
  <p>paragraph</p>
  <img src="/images/img-1.jpg" alt="alt for image">
</div>
Or I may have:
<div class="article">
  <h3>heading</h3>
  <p><img src="/images/img-1.jpg" alt="alt for image"> some paragraph </p>
</div>
So, I may have anything inside .article div and from which I wanted to replace img to div like
From:
<img src="/images/img-1.jpg" alt="alt for image" here-may-be-another-attribute-too>
To:
<div style="background: transparent url(/images/img-1.jpg) no-repeat;">alt for image</div>
 
     
     
     
     
     
     
     
     
     
     
     
     
     
    