Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions classes/Tools/Storage/CLI/StorageCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
20 changes: 16 additions & 4 deletions classes/Tools/Storage/StorageTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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'])) {
Expand Down
2 changes: 1 addition & 1 deletion ilab-media-tools.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
Plugin Name: Media Cloud
Plugin Name: Media Cloud Fork
Plugin URI: https://github.com/interfacelab/ilab-media-tools
Description: Automatically upload media to Amazon S3 and integrate with Imgix, a real-time image processing CDN. Boosts site performance and simplifies workflows.
Author: interfacelab
Expand Down