diff --git a/classes/Tools/Storage/CLI/StorageCommands.php b/classes/Tools/Storage/CLI/StorageCommands.php index c64b2b5d..31d9fc52 100755 --- a/classes/Tools/Storage/CLI/StorageCommands.php +++ b/classes/Tools/Storage/CLI/StorageCommands.php @@ -110,10 +110,21 @@ public function import($args, $assoc_args) { $skipThumbnails = (!empty($assoc_args['skip-thumbnails'])) ? true : false; + $product_posts = new \WP_Query( + array( + 'post_type' => 'product', // adjust your custom post type name here + 'posts_per_page' => -1, + 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'), + 'fields' => 'ids' + ) + ); + $postArgs = [ 'post_type' => 'attachment', 'post_status' => 'inherit', + 'nopaging' => true, 'fields' => 'ids', + 'post_parent__in' => $product_posts->posts, ]; if (isset($assoc_args['limit'])) { diff --git a/classes/Tools/Storage/StorageTool.php b/classes/Tools/Storage/StorageTool.php index 60842b71..f7083e60 100755 --- a/classes/Tools/Storage/StorageTool.php +++ b/classes/Tools/Storage/StorageTool.php @@ -1368,12 +1368,14 @@ public function filterContent($content) { $textSize = null; $cleanedUrl = null; $size = 'full'; + $sizePrefix = '-'; + $sizeSeparator = 'x'; - if (preg_match('/(-[0-9x]+)\.(?:jpg|gif|png)/m', $matchedUrl, $sizeMatches)) { + if (preg_match("/({$sizePrefix}\d+{$sizeSeparator}\d+)\.(?:jpg|gif|png)/mi", $matchedUrl, $sizeMatches)) { $cleanedUrl = str_replace($sizeMatches[1], '', $matchedUrl); $id = attachment_url_to_postid($cleanedUrl); - $textSize = trim($sizeMatches[1], '-'); - $size = explode('x', $textSize); + $textSize = trim($sizeMatches[1], $sizePrefix); + $size = explode($sizeSeparator, $textSize); } else { $id = attachment_url_to_postid($matchedUrl); } @@ -1555,7 +1557,9 @@ public function processFile($upload_path, $filename, $data, $id = null, $preserv $prefix = StorageSettings::prefix($id); } } - + + $prefix = apply_filters( 'ilab_storage_prefix', $prefix ); + $parts = explode('/', $filename); $bucketFilename = array_pop($parts); @@ -1606,6 +1610,14 @@ public function processFile($upload_path, $filename, $data, $id = null, $preserv 'options' => $options ]; + /** + * Change by Novembit + * store filesize to meta + */ + if( file_exists( $upload_path.'/'.$filename ) ) { + $data['filesize'] = filesize( $upload_path.'/'.$filename ); + } + if(file_exists($upload_path.'/'.$filename)) { $ftype = wp_check_filetype($upload_path.'/'.$filename); if(!empty($ftype) && isset($ftype['type'])) { diff --git a/ilab-media-tools.php b/ilab-media-tools.php index 4d513c39..2475a85c 100755 --- a/ilab-media-tools.php +++ b/ilab-media-tools.php @@ -1,7 +1,7 @@