diff --git a/classes/tasks/ilab-s3-import-process.php b/classes/tasks/ilab-s3-import-process.php index 9a8d9467..5230308b 100644 --- a/classes/tasks/ilab-s3-import-process.php +++ b/classes/tasks/ilab-s3-import-process.php @@ -43,7 +43,8 @@ public function task($item) { $file = _wp_relative_upload_path($upload_file); $data = [ 'file' => $file ]; if (file_exists($upload_file)) { - $mime = trim(`file --mime-type -b {$upload_file}`); + $mime = mime_content_type($upload_file); + if ($mime == 'image/vnd.adobe.photoshop') { $mime = 'application/vnd.adobe.photoshop'; } diff --git a/classes/tools/s3/ilab-media-s3-tool.php b/classes/tools/s3/ilab-media-s3-tool.php index a1d7067f..e329b7b3 100644 --- a/classes/tools/s3/ilab-media-s3-tool.php +++ b/classes/tools/s3/ilab-media-s3-tool.php @@ -26,6 +26,7 @@ class ILabMediaS3Tool extends ILabMediaToolBase { private $key = null; private $secret = null; private $bucket = null; + private $endpoint = null; private $docCdn = null; private $cdn = null; private $deleteOnUpload = false; @@ -58,6 +59,7 @@ public function __construct($toolName, $toolInfo, $toolManager) $this->bucket = $this->getOption('ilab-media-s3-bucket', 'ILAB_AWS_S3_BUCKET'); $this->key = $this->getOption('ilab-media-s3-access-key', 'ILAB_AWS_S3_ACCESS_KEY'); $this->secret = $this->getOption('ilab-media-s3-secret', 'ILAB_AWS_S3_ACCESS_SECRET'); + $this->endpoint = $this->getOption('ilab-media-s3-endpoint', 'ILAB_AWS_S3_ENDPOINT'); $this->deleteOnUpload = $this->getOption('ilab-media-s3-delete-uploads'); $this->deleteFromS3 = $this->getOption('ilab-media-s3-delete-from-s3'); $this->prefixFormat = $this->getOption('ilab-media-s3-prefix', ''); @@ -222,8 +224,12 @@ public function editAttachment($post_id) { private function editDocumentAttachment() { global $post; + if (empty($post)) { + return; + } + $meta = get_post_meta($post->ID, 'ilab_s3_info', true); - if (!isset($meta['s3'])) { + if (empty($meta) || !isset($meta['s3'])) { return; } @@ -318,41 +324,49 @@ public function renderS3InfoMeta() { global $post; $meta = wp_get_attachment_metadata($post->ID); + if (empty($meta)) { + echo 'gay'; + + return; + } + if (!isset($meta['s3'])) { $meta = get_post_meta($post->ID, 'ilab_s3_info', true); } - if (!isset($meta['s3'])) { + if (empty($meta) || !isset($meta['s3'])) { ?> Not uploaded to S3. -
- Bucket: -
-
- Path: -
-
- - -
-
- - -
-
- - -
-
- View S3 URL -
- +
+ Bucket: +
+
+ Path: +
+
+ + +
+
+ + +
+
+ + +
+
+ View S3 URL +
+ s3enabled()) return null; - $s3=new \ILAB_Aws\S3\S3MultiRegionClient([ - 'version' => 'latest', - 'credentials' => [ - 'key' => $this->key, - 'secret' => $this->secret - ] - ]); + $config = [ + 'version' => 'latest', + 'credentials' => [ + 'key' => $this->key, + 'secret' => $this->secret + ] + ]; + + if ($this->endpoint) { + $config['endpoint'] = $this->endpoint; + } + + $s3=new \ILAB_Aws\S3\S3MultiRegionClient($config); if ($insure_bucket && !$this->skipBucketCheck) { if (!$s3->doesBucketExist($this->bucket)) { @@ -901,6 +921,8 @@ public function settingsChanged() { } public function renderImporter() { + $enabled = $this->s3enabled(); + $status = get_option('ilab_s3_import_status', false); $total = get_option('ilab_s3_import_total_count', 0); $current = get_option('ilab_s3_import_current', 1); @@ -924,7 +946,8 @@ public function renderImporter() { 'status' => ($status) ? 'running' : 'idle', 'total' => $total, 'progress' => $progress, - 'current' => $current + 'current' => $current, + 'enabled' => $enabled ]); } @@ -1051,7 +1074,7 @@ public function prepareAttachmentForJS($response, $attachment, $meta ) { if (empty($meta) || !isset($meta['s3'])) { $meta = get_post_meta($attachment->ID, 'ilab_s3_info', true); } - + if (isset($meta['s3'])) { $response['s3'] = $meta['s3']; diff --git a/ilab-media-tools.php b/ilab-media-tools.php index 10112c8d..186c4e4e 100644 --- a/ilab-media-tools.php +++ b/ilab-media-tools.php @@ -4,7 +4,7 @@ Plugin URI: http://interfacelab.com/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 -Version: 1.4.8 +Version: 1.4.9 Author URI: http://interfacelab.io */ diff --git a/readme.txt b/readme.txt index 0fc39f19..2399661f 100644 --- a/readme.txt +++ b/readme.txt @@ -1,12 +1,12 @@ === Media Cloud by ILAB === Contributors: interfacelab -Tags: media, images, cdn, uploads, crop, imgix, s3, cloudfront, aws, amazon s3, image editing, image editor, mirror, media library, offload, offload s3 +Tags: media, images, cdn, uploads, crop, imgix, s3, cloudfront, aws, amazon s3, image editing, image editor, mirror, media library, offload, offload s3, minio, google cloud storage, digital ocean spaces Requires at least: 4.4 Tested up to: 4.8.1 License: GPLv3 or later Donate link: http://www2.jdrf.org/site/TR?fr_id=6912&pg=personal&px=11429802 License URI: http://www.gnu.org/licenses/gpl-3.0.html -Stable tag: 1.4.8 +Stable tag: 1.4.9 Automatically upload media to Amazon S3 and integrate with Imgix, a real-time image processing CDN. Boosts site performance and simplifies workflows. @@ -17,9 +17,9 @@ Media Cloud by ILAB is a suite of tools designed to enhance media handling in Wo **NOTE**: This plugin requires PHP 5.5x or higher (PHP 7.x preferred) -= Upload to S3 = -Automatically copy media uploads to S3 and hosts your media directly -from S3 or CloudFront. Additionally, easily import your existing += Upload to S3, Mini, Google Cloud Storage and Digital Ocean Spaces = +Automatically copy media uploads to S3 (and S3 compatible services) and hosts your media directly +from S3, CloudFront or any other CDN. Additionally, easily import your existing media library to Amazon S3 with the push of a button. = Integrate with Imgix = @@ -98,6 +98,10 @@ No, I'm just one very enthusiastic customer. 5. Imgix settings. == Changelog == += 1.4.9 = +* Compatibility with S3-compatible services like Minio, Google Cloud Storage (when in interoperability mode) and Digital Ocean Spaces. (thanks to Vladimir Pouzanov) +* Misc. fixes + = 1.4.7 = * Fixed collision with Types plugin * Added donation link. If you find this plugin useful, PLEASE donate to my JDRF fund raiser for finding a cure for type 1 diabetes. diff --git a/tools.json b/tools.json index fd8b160d..614ee061 100644 --- a/tools.json +++ b/tools.json @@ -401,6 +401,18 @@ } } }, + "ilab-media-s3-aws-custom-endpoint-settings": { + "title": "Custom End Point (Advanced)", + "description": "ILAB Media Cloud is compatible with any S3 compatible cloud storage server like Minio, Ceph RGW, Google Cloud Storage (when in interoperability mode) or Digital Ocean Spaces. If you are using one of these services, specify the endpoint for the service's api here. IMPORTANT: If you are using Minio, your bucket must have a public read policy set for the entire bucket. See here for more details.", + "options": { + "ilab-media-s3-endpoint": { + "title": "Custom Endpoint URL", + "description": "If you are supplying this value through a .env file, or environment variables, the key is: ILAB_AWS_S3_ENDPOINT", + "type": "text-field", + "watch": true + } + } + }, "ilab-media-s3-upload-handling-settings": { "title": "Upload Handling", "description": "The following options control how the S3 tool handles uploads.", diff --git a/views/s3/ilab-s3-importer.php b/views/s3/ilab-s3-importer.php index 614851d2..54159b08 100644 --- a/views/s3/ilab-s3-importer.php +++ b/views/s3/ilab-s3-importer.php @@ -17,6 +17,11 @@ height: 100%; width: {{$progress}}%; } + + .tool-disabled { + padding: 10px 15px; + border: 1px solid #df8403; + }

S3 Importer

@@ -27,10 +32,14 @@
  1. If you upload any files while this process is running, you'll need to run this tool again after it finishes.
  2. This process DOES NOT delete your files on your server, you'll have to do that yourself manually.
  3. -
  4. It's recommended that you have the S3 tool disabled in Tools Settings before running this task.
  5. +
  6. You MUST HAVE S3 enabled and working in Tools Settings before running this task.
+ Import Uploads + + Please enable S3 before using this tool. +