chinesedom
02-22-2012, 10:25 AM
Hey folks,
I use a plugin for wordpress called Image Voting from Flaunt books (http://www.flauntbooks.com/wordpress-plugins/image-voting-plugin.html).
The script does find ordinary images just like these:
<img src="http://www.traumhafte-abendkleider.de/wp-content/themes/peaceful-rush_1/images/abendkleider_abendkleid_logo01.jpg" alt="Traumhafte-Abendkleider" />
But it doesnt work with images like these:
<div id="ngg-image-160" class="ngg-gallery-thumbnail-box" >
<div class="ngg-gallery-thumbnail" >
<a href="http://www.traumhafte-abendkleider.de/wp-content/gallery/rubensengel_kinderkleider/kleid-blumenkind-mintgruen.jpg" title=" " >
<img title="Blumenkind Kleid mintgruen" alt="Blumenkind Kleid mintgruen" src="http://www.traumhafte-abendkleider.de/wp-content/gallery/rubensengel_kinderkleider/thumbs/thumbs_kleid-blumenkind-mintgruen.jpg" width="400" height="600" />
</a>
</div>
</div>
I checked the code for quite a while and think the problem might be somewhere with the preg_match_all or contents of $pattern1 / $pattern2.
What can I do to find all images???
This is the code to find the images:
function _find_images( $content )
{
$pattern1 = "/<(a[^>]*)><(img[^>]*)><\/a>/i";
$pattern2 = "#<img(.*)src=(.*)>#i";
preg_match_all( $pattern1, $content, $res1 );
preg_match_all( $pattern2, $content, $res2 );
$tmppics = array();
foreach($res1[0] as $html){
if($fb['imagevote_debug']){ echo 'res='.$res; } // debug by dom
$pos = strpos($html, "novote"); // if class = novote don't add voting
// kommentiert von dominik $pos2 = strpos($html, "gallery-holder"); // p3 flash & lightbox galleries
$pos2 = false;
// $pos = strpos($html, "attachment-thumbnail"); // if class = attachment-thumbnail
if ($pos === false && $pos2 === false) {
$tmppics[] = ImageVote::_parse_image( $html );
echo $pos . '=pos ; pos2 = '. $pos2; // debug von dom
}
}
foreach($res2[0] as $html){
if($fb['imagevote_debug']){ echo 'res2='.$res2; } // debug by dominik
$pos = strpos($html, "novote"); // if class = novote don't add voting
// kommentiert von dominik $pos2 = strpos($html, "gallery-holder"); // p3 flash & lightbox galleries
$pos2 = false;
// $pos = strpos($html, "attachment-thumbnail"); // if class = attachment-thumbnail
if ($pos === false && $pos2 === false) {
$tmppics[] = ImageVote::_parse_image( $html );
echo $pos . '=pos ; pos2 = '. $pos2; // debug von dom
}
}
$links = array();
$pics = array();
foreach($tmppics as $pic)
if($pic['src'])
if(!$links[$pic['src']])
{
$links[$pic['src']] = 1;
$pics[] = $pic;
}
echo 'DEBUG->PICCOUNT2:'.count($pics);
return $pics;
}
I use a plugin for wordpress called Image Voting from Flaunt books (http://www.flauntbooks.com/wordpress-plugins/image-voting-plugin.html).
The script does find ordinary images just like these:
<img src="http://www.traumhafte-abendkleider.de/wp-content/themes/peaceful-rush_1/images/abendkleider_abendkleid_logo01.jpg" alt="Traumhafte-Abendkleider" />
But it doesnt work with images like these:
<div id="ngg-image-160" class="ngg-gallery-thumbnail-box" >
<div class="ngg-gallery-thumbnail" >
<a href="http://www.traumhafte-abendkleider.de/wp-content/gallery/rubensengel_kinderkleider/kleid-blumenkind-mintgruen.jpg" title=" " >
<img title="Blumenkind Kleid mintgruen" alt="Blumenkind Kleid mintgruen" src="http://www.traumhafte-abendkleider.de/wp-content/gallery/rubensengel_kinderkleider/thumbs/thumbs_kleid-blumenkind-mintgruen.jpg" width="400" height="600" />
</a>
</div>
</div>
I checked the code for quite a while and think the problem might be somewhere with the preg_match_all or contents of $pattern1 / $pattern2.
What can I do to find all images???
This is the code to find the images:
function _find_images( $content )
{
$pattern1 = "/<(a[^>]*)><(img[^>]*)><\/a>/i";
$pattern2 = "#<img(.*)src=(.*)>#i";
preg_match_all( $pattern1, $content, $res1 );
preg_match_all( $pattern2, $content, $res2 );
$tmppics = array();
foreach($res1[0] as $html){
if($fb['imagevote_debug']){ echo 'res='.$res; } // debug by dom
$pos = strpos($html, "novote"); // if class = novote don't add voting
// kommentiert von dominik $pos2 = strpos($html, "gallery-holder"); // p3 flash & lightbox galleries
$pos2 = false;
// $pos = strpos($html, "attachment-thumbnail"); // if class = attachment-thumbnail
if ($pos === false && $pos2 === false) {
$tmppics[] = ImageVote::_parse_image( $html );
echo $pos . '=pos ; pos2 = '. $pos2; // debug von dom
}
}
foreach($res2[0] as $html){
if($fb['imagevote_debug']){ echo 'res2='.$res2; } // debug by dominik
$pos = strpos($html, "novote"); // if class = novote don't add voting
// kommentiert von dominik $pos2 = strpos($html, "gallery-holder"); // p3 flash & lightbox galleries
$pos2 = false;
// $pos = strpos($html, "attachment-thumbnail"); // if class = attachment-thumbnail
if ($pos === false && $pos2 === false) {
$tmppics[] = ImageVote::_parse_image( $html );
echo $pos . '=pos ; pos2 = '. $pos2; // debug von dom
}
}
$links = array();
$pics = array();
foreach($tmppics as $pic)
if($pic['src'])
if(!$links[$pic['src']])
{
$links[$pic['src']] = 1;
$pics[] = $pic;
}
echo 'DEBUG->PICCOUNT2:'.count($pics);
return $pics;
}