fork download
  1. <?php
  2. $content = <<<'STR'
  3. <img class="leftimg"
  4. src="https://e...content-available-to-author-only...e.ru/img/shema/2016-05-20%2013-58-37.jpg"
  5. alt="Забор из профнастила" width="550" height="309" />
  6. STR;
  7.  
  8. $content = preg_replace('!<img(.*?)src(.*?)alt="(.*?)" width(.*?)height(.*?)\s\/>!si',
  9. '<span itemscope itemtype="https://s...content-available-to-author-only...a.org/ImageObject">
  10. <span itemprop="name" style="display:none;">\\3</span>
  11. <span itemprop="author" style="display:none;">Author</span>
  12. <img itemprop="url contentUrl" \\1 src\\2 alt="\\3" title="\\3" width\\4 height\\5 />
  13. <meta itemprop="width" content\\4>
  14. <meta itemprop="height" content\\5></span>',$content);
  15.  
  16. echo $content;
Success #stdin #stdout 0.02s 23724KB
stdin
Standard input is empty
stdout
<span itemscope itemtype="https://s...content-available-to-author-only...a.org/ImageObject">
<span itemprop="name" style="display:none;">Забор из профнастила</span>
<span itemprop="author" style="display:none;">Author</span>
<img itemprop="url contentUrl"  class="leftimg" 
 src="https://e...content-available-to-author-only...e.ru/img/shema/2016-05-20%2013-58-37.jpg" 
 alt="Забор из профнастила" title="Забор из профнастила" width="550"  height="309" />
<meta itemprop="width" content="550" >
<meta itemprop="height" content="309"></span>