From: Steve Sutton Date: Fri, 31 Jul 2015 19:25:15 +0000 (-0400) Subject: Update for agriculture page X-Git-Tag: v0.0.2^2~18 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=fff57d29e07be8e38ff3aa622246af4285ee29e6;p=WP-Plugins%2Fglm-wp-importer.git Update for agriculture page --- diff --git a/controllers/Import.php b/controllers/Import.php index 9db9f72..e64490e 100644 --- a/controllers/Import.php +++ b/controllers/Import.php @@ -828,7 +828,7 @@ FROM {$wpdb->prefix}posts WHERE post_content LIKE '%get_results($sql, OBJECT); echo '

'.count($results).'

'; if (count($results) > 0) { @@ -846,23 +846,39 @@ } if ($image->hasAttribute('style')) { $style = $image->getAttribute('style'); - //echo '
' . print_r($style, true)  . '
'; - if (preg_match(';width[: ]+(\d+)px;', $style, $wMatch)) { + echo '
' . print_r($style, true)  . '
'; + if (preg_match(';[^-]width[: ]+(\d+)px;', $style, $wMatch)) { $width = $wMatch[1]; } - if (preg_match(';height[: ]+(\d+)px;', $style, $hMatch)) { + if (preg_match(';[^-]height[: ]+(\d+)px;', $style, $hMatch)) { $height = $hMatch[1]; } - //echo '
' . print_r($width, true)  . '
'; - //echo '
' . print_r($height, true)  . '
'; + echo '
' . print_r($width, true)  . '
'; + echo '
' . print_r($height, true)  . '
'; } if ($image->hasAttribute('src')) { //echo '
' . print_r($image->getAttribute('src'), true)  . '
'; $imgName = basename($image->getAttribute('src')); - //echo '
' . print_r($imgName, true)  . '
'; + echo '
' . print_r($imgName, true)  . '
'; $imgPathInfo = pathinfo($imgName); $wpImage = $this->_getAttachmentByName($imgPathInfo['filename']); - //echo '
' . print_r($wpImage, true) . '
'; + if (!$wpImage) { + echo '
' . print_r($image->getAttribute('src'), true) . '
'; + $parsed = parse_url($image->getAttribute('src')); + $filename = basename($parsed['path']); + if (preg_match(';is\d{2,}-\d{10,}-\d{5,};', $filename)) { + $rootUrl = str_replace('/' . $filename, '', $image->getAttribute('src')); + echo '
' . print_r($parsed, true) . '
'; + echo '
' . print_r($filename, true) . '
'; + echo '
' . print_r($rootUrl, true) . '
'; + $wpImage = $this->_handleMediaFile( + basename($parsed['path']), + '', + $post->ID, + $rootUrl . '/' + ); + } + } if ($wpImage) { //$strToReplace = $dom->saveHTML($image); //echo '
'.htmlspecialchars($strToReplace).'
'; @@ -915,7 +931,7 @@ $dom->saveHTML() ) ); - //echo '
'.print_r(htmlspecialchars($content), true).'
'; + echo '
'.print_r(htmlspecialchars($content), true).'
'; $updatePost = array( 'ID' => $post->ID, 'post_content' => $content