image - PHP process IMG with specific width & order… -


i want img tags inside $_post['textarea'], change this:

example:

$_post['textarea'] = <b>some example text</b><br> <img src="image_1.jpg" alt="bla bla" width="250" height="100" /> <u>some more text</u><br> <img src="image_2.jpg" alt="bla bla" width="50" height="20" /> 

to format this:

$final = <b>some example text</b> <a class="fancybox" rel="gallery1" href="image_1.jpg" title="bla bla"><img src="image_1.jpg" alt="bla bla" width="250" height="100" /></a> </u>some more text</u> <img src="image_2.jpg" alt="bla bla" width="50" height="20" /> 
  1. how can add class="fancybox" img tags width greater 50px ?
  2. how can process img tags in order according values?
  3. how can print whole content of var $_post['textarea'] tags , text & updated img tags, in var $final?

include simple_html_dom.php in page. download http://en.sourceforge.jp/projects/sfnet_simplehtmldom/downloads/simplehtmldom/1.10/simplehtmldom_1_10.zip/

 <?php require_once('controller/simple_html_dom.php'); $str = 'some example text <img src="image_1.jpg" alt="bla bla" width="250" height="100" />          more text <img src="image_2.jpg" alt="bla bla" width="50" height="20" />';  $html = str_get_html($str); $img = array(); foreach ($html->find('img') $images) {     if($images->getattribute('width') > 50) {         $img[] = '<a class="fancybox" rel="gallery1" href="'.$images->getattribute('src').'" title="bla bla">'.$images.'</a>';     } else {         $img[] = $images;     } }  $full = '';  $i = 0; foreach ($html->find('text') $text) {     $full .= $text.$img[$i];     $i++; } echo $full; ?> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -