View Single Post
Old 05-19-2012, 01:56 AM  
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,383
The TGP parsing code above has an issue with the thumbnail count. Here is the fixed version:

Code:
if (!cseo_post_exists($post)) {
    $max_images = 20;
    $thumb_width = 180;
    $thumb_height = 240;
    $link = "http://www.google.com/";
    add_image_size('thumbnail', $thumb_width, $thumb_height, true);
    $gallery = cseo_file_get_contents($post['link']);
    preg_match_all('/<a.+?href=[\s]?["|\']([\w%-\.\/:\?&=]+\.(jpg|jpeg|png|gif))["|\'].*?>.*?<img.*?src.*?>/is', html_entity_decode($gallery), $matches);
    for ($i = 0; $i < min(((int) (count($matches[1]) / 4)) * 4, $max_images); $i++) {
        if (stripos($matches[1][$i], ".jpg") !== false) {
            if (stripos($matches[1][$i], "http://") !== false) {
                $image = $matches[1][$i];
            } elseif (substr($matches[1][$i], 0, 1) == "/") {
                $image = "http://" . parse_url($post['link'], PHP_URL_HOST) . $matches[1][$i];
            } else {
                $image = str_replace(basename($post['link']), "", $post['link']) . $matches[1][$i];
            }
            cseo_add_image_to_library($image, $post['post_title']);
        }
    }
    $post['post_excerpt'] = strip_tags($post['post_excerpt']) . '<p>[gallery columns="4"]</p>';
    $post['post_excerpt'] .= "<h2 align=\"center\"><a href=\"" . $link . "\" target=\"_blank\">Click Here For More!</a></h2>\n";
} else {
    $post = false;
}
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote