title: How to add rel="lightbox" only to links which are including an image and not the rest of the links?
body: <p>Lets say that (in php) we have a variable which has text, links and images :</p>
  
  <pre><code>&lt;a href="myimage_big"&gt;&lt;img src="myimage.jpg" alt="pic" title="pic" border="0" /&gt;&lt;/a&gt;
  </code></pre>
  
  <p>and we want to add to every a href tag the rel="light" as follow :</p>
  
  <pre><code>&lt;a rel="lightbox" href="myimage_big"&gt;&lt;img src="myimage.jpg" alt="pic" title="pic" border="0" /&gt;&lt;/a&gt;
  </code></pre>
  
  <p>If the name of the variable is lets say <strong>$mydata</strong> then with str_replace we can do as follow to solve our problem :</p>
  
  <pre><code>$mydata = str_replace('&lt;img ', '&lt;img rel="lightbox"', $mydata);
  </code></pre>
  
  <p>Till here is all right, but what about the rest of the a href links that are not including any photo :</p>
  
  <p>par example,</p>
  
  <pre><code>&lt;a href="link1.php"&gt;link_no1&lt;/a&gt;
  &lt;a href="link2.php"&gt;link_no2&lt;/a&gt;
  </code></pre>
  
  <p>etc ? To this kind of links that are not including any image but text then with our str_replace code will also have a rel="lightbox" attribute that is not correct and i dont want :</p>
  
  <pre><code>&lt;a rel="lightbox" href="link1.php"&gt;link_no1&lt;/a&gt;
  </code></pre>
  
  <p>So how we can apply the rel="lightbox" <strong>only</strong> to the links that are including some image and to those links that are not including any image to dont set the rel="lightbox" attribute ..!?</p>