From: Steve Sutton Date: Thu, 29 Jun 2017 18:33:30 +0000 (-0400) Subject: Updating the photos import X-Git-Tag: v2.10.0^2~11^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=00617d05f307688f0c56f430f35ce91ae27bb689;p=WP-Plugins%2Fglm-member-db.git Updating the photos import Bumping up the per process count to 40 for photos and files. --- diff --git a/models/admin/ajax/imageUpload.php b/models/admin/ajax/imageUpload.php index fd2ba6af..96ec13db 100644 --- a/models/admin/ajax/imageUpload.php +++ b/models/admin/ajax/imageUpload.php @@ -217,6 +217,7 @@ class GlmMembersAdmin_ajax_imageUpload extends GlmDataImages // Finally, move the files to the various size directories and rename them back to the correct name reset ($this->config['imageSizes']); + while (list($k, $v) = each($this->config['imageSizes'])) { // Check if size directory needs to be made @@ -226,14 +227,19 @@ class GlmMembersAdmin_ajax_imageUpload extends GlmDataImages // If there's an entry in the $sizes array, it means that the image resized to this size if (isset($sizes[$k])) { - // Move resized file to desired direectory - rename(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$sizes[$k]['file'], GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$newFilename); + // Copy resized file to desired directory + copy(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$sizes[$k]['file'], GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$newFilename); } else { // Image didn't resize to this size, probably because it was smaller than the destination size (silly WP Image Editor class) - so just use the original copy(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$newFilename, GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k.'/'.$newFilename); } } + // Since we copied the files from the main images directory we need + // some clean-up here. + foreach ( $sizes as $imgSize => $imgData ) { + @unlink( GLM_MEMBERS_PLUGIN_IMAGES_PATH . '/' . $imgData['file'] ); + } // Move the original to original directory if (!file_exists(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/original')) { diff --git a/models/admin/import/index.php b/models/admin/import/index.php index f009a3ba..35ceb2b7 100644 --- a/models/admin/import/index.php +++ b/models/admin/import/index.php @@ -108,14 +108,14 @@ class GlmMembersAdmin_import_index * @var float * @access public */ - public $fileProcessCountPerRound = 10; + public $fileProcessCountPerRound = 40; /** * photoProcessCountPerRound * * @var float * @access public */ - public $photoProcessCountPerRound = 10; + public $photoProcessCountPerRound = 40; /** * numberProcessed @@ -530,8 +530,8 @@ class GlmMembersAdmin_import_index // We have to add one to $ending (array starts at 1 not 0). $ending++; for ( $index = $start; $index < $ending; $index++ ) { - //foreach ( $photoData as $photo ) { $photo = $photoData[$index]; + $this->photosProcessed++; // If there's no url or the url is not valid then skip it. if ( $photoUrl = filter_var( $photo['image'], FILTER_VALIDATE_URL ) ) { // Need to first get the member id from the database @@ -553,15 +553,20 @@ class GlmMembersAdmin_import_index if ( !$memberInfoId ) { continue; } + // There's a character limit on the photo caption field + // of 255 (mysql TINYTEXT) + $caption = substr( $photo['caption'], 0, 250 ); $res = $ImageUpload->storeImage( $photoUrl, $refType, $refTable, $memberInfoId, - $photo['caption'] + $caption ); + if ( !$res ) { + $this->errors = true; + } } - $this->photosProcessed++; } @@ -609,6 +614,7 @@ class GlmMembersAdmin_import_index $ending++; for ( $index = $start; $index < $ending; $index++ ) { $file = $filesData[$index]; + $this->filesProcessed++; // If there's no url or the url is not valid then skip it. if ( $fileUrl = filter_var( $file['file_url'], FILTER_VALIDATE_URL ) ) { // Need to first get the member id from the database @@ -638,7 +644,6 @@ class GlmMembersAdmin_import_index $file['file_name'] ); } - $this->filesProcessed++; } diff --git a/views/admin/import/photosProcess.html b/views/admin/import/photosProcess.html index 4127b08c..8d16cfe7 100644 --- a/views/admin/import/photosProcess.html +++ b/views/admin/import/photosProcess.html @@ -28,7 +28,7 @@ - {if !$completed} + {if !$completed && !$errors} {$newStart = 1 + $photosProcessed}