echo '<pre>Caption Text: ' . print_r($cMatch[2][$index], true) . '</pre>';
if (preg_match('%src="([^"]+)"%', $cMatch[1][$index], $srcMatch)) {
echo '<pre>Sub Src Match: ' . print_r($srcMatch[1], true) . '</pre>';
+ $fileInfo = pathinfo($srcMatch[1]);
$fileName = basename($srcMatch[1]);
+ $fileName = $fileInfo['filename'];
echo '<pre>File Name: ' . print_r($fileName, true) . '</pre>';
$path = str_replace($fileName, '', $srcMatch[1]);
+ $path = $filInfo['dirname'];
$imagesKey = $this->_getAttachmentByName($fileName);
var_dump($imagesKey);
if (!$imagesKey) {
}
}
}
+ // In this next part Have to remember the $content is already processed.
+ // Don't edit src if they alrea,dy have an ID
if (preg_match_all('%<img ([^>]+)>%', $content, $matches)) {
$imageCount = count($matches[0]);
for ($index = 0; $index < $imageCount; ++$index) {
echo '<pre>Image Match: ' . $imageCount . '</pre>';
echo '<pre>'.htmlspecialchars($matches[0][$index]).'</pre>';
+ if (!(($uploads = wp_upload_dir()) && false === $uploads['error'])) {
+ return new WP_Error('upload_error', $uploads['error']);
+ }
+ echo '<pre>Uploads Url: ' . print_r($uploads['url'], true) . '</pre>';
+ if (preg_match('%src="' . $uploads['url'] . '[^"]+"%', $matches[1][$index], $pMatch)) {
+ continue;
+ }
if (preg_match('%src="([^"]+)"%', $matches[1][$index], $srcMatch)) {
echo '<pre>Sub Src Match: ' . print_r($srcMatch[1], true) . '</pre>';
- $fileName = basename($srcMatch[1]);
+ $fileInfo = pathinfo($srcMatch[1]);
+ echo '<pre>' . print_r($fileInfo, true) . '</pre>';
+ $fileName = $fileInfo['filename'];
echo '<pre>File Url: ' . print_r($srcMatch[1], true) . '</pre>';
echo '<pre>File Name: ' . print_r($fileName, true) . '</pre>';
- $path = str_replace($fileName, '', $srcMatch[1]);
+ $path = $filInfo['dirname'];
echo '<pre>File Path: ' . print_r($path, true) . '</pre>';
$imagesKey = $this->_getAttachmentByName($fileName);
var_dump($imagesKey);
SELECT *
FROM {$wpdb->prefix}posts
WHERE post_type = 'attachment'
- AND (post_name = '{$name}' OR post_title = '{$name}')";
+ AND (post_name like '{$name}%' OR post_title like '{$name}%')";
$results = $wpdb->get_results($sql, OBJECT);
return (!empty($results)) ? $results[0]->ID : false;
//return (!empty($results)) ? $results[0] : false;
echo '<pre>' . print_r($filename, true) . '</pre>';
echo '<pre>' . print_r($rootUrl, true) . '</pre>';
$img_id = $this->_handleMediaFile(
- basename($parsed['path']),
+ $filename,
'',
$post->ID,
$rootUrl . '/'
$this->_updateFilesHref();
echo '<p>Done</p>';
echo '<p><a href="admin.php?import=toolbox&step=5">Step Five (Updating Url\'s and keywords)</a></p>';
+ break;
case 5:
echo '<p>Phase Five</p>';
echo '<p>Site Url</p>';