Please see the next code.
<p>
<img src="http://jdjd" alt="" /><br />
Hola mama<br />
fdffdfdfdfd <img src="http://jdjd" alt="" /><br />
<img src="http://jdjd" alt="" /><br />
<span>Hola</span>
</p>
Then, the following draw it
Note that I've inserted three <img>
, two of them are the only element in a line and the another one is next to a text (fdffd.. + img).
I don't know how to resolve this issue, but I would like when a <img>
is not the only element in a line, insert a class called center
. So the result would be the next:
<p>
<img class="center" src="http://jdjd" alt="" /><br />
Hola mama<br />
fdffdfdfdfd <img src="http://jdjd" alt="" /><br />
<img class="center" src="http://jdjd" alt="" /><br />
<span>Hola</span>
</p>
I guess this can be resolve using Regular Expressions, but I don't know how to use it.