diff --git a/classes/Tasks/Model.php b/classes/Model/Model.php similarity index 78% rename from classes/Tasks/Model.php rename to classes/Model/Model.php index e8463ca7..2b2f50f6 100755 --- a/classes/Tasks/Model.php +++ b/classes/Model/Model.php @@ -11,11 +11,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // ********************************************************************** -namespace ILAB\MediaCloud\Tasks; - -use function ILAB\MediaCloud\Utilities\arrayPath; -use function ILAB\MediaCloud\Utilities\gen_uuid; -use ILAB\MediaCloud\Utilities\Logging\Logger; +namespace ILAB\MediaCloud\Model; /** * Represents a database model @@ -59,6 +55,13 @@ abstract class Model { */ protected $serializedProperties = []; + /** + * Name of properties that are JSON serialized, must map to database and must be properties on model class. + * + * @var array + */ + protected $jsonProperties = []; + //endregion //region Static Methods @@ -99,6 +102,10 @@ public function __construct($data = null) { if (property_exists($data, $prop)) { if (in_array($prop, $this->serializedProperties)) { $this->{$prop} = maybe_unserialize($data->{$prop}); + } else if (in_array($prop, $this->jsonProperties)) { + if (!empty($data->{$prop})) { + $this->{$prop} = json_decode($data->{$prop}, true); + } } else { $this->{$prop} = $data->{$prop}; } @@ -186,6 +193,14 @@ public function save() { foreach($this->modelProperties as $prop => $format) { if (in_array($prop, $this->serializedProperties)) { $data[$prop] = maybe_serialize($this->{$prop}); + $formats[] = '%s'; + } else if (in_array($prop, $this->jsonProperties)) { + if (!empty($this->{$prop})) { + $data[$prop] = json_encode($this->{$prop}, JSON_PRETTY_PRINT); + } else { + $data[$prop] = null; + } + $formats[] = '%s'; } else { $data[$prop] = $this->{$prop}; @@ -211,6 +226,13 @@ public function save() { return false; } + /** + * Called before the model deletes itself + */ + protected function willDelete() { + + } + /** * Deletes the model. * @@ -222,6 +244,8 @@ public function delete() { return false; } + $this->willDelete(); + global $wpdb; $result = $wpdb->delete(static::table(), ['id' => $this->id]); @@ -256,5 +280,40 @@ public static function instance($id) { return null; } + + /** + * Returns all of the models + * + * @param null|string $orderBy + * @param int $limit + * @param int $page + * + * @return Model|null + * @throws \Exception + */ + public static function all($orderBy = null, $limit = 0, $page = 0) { + global $wpdb; + + $table = static::table(); + + $query = "select * from {$table}"; + + if (!empty($orderBy)) { + $query = "{$query} order by {$orderBy}"; + } + + if (!empty($limit)) { + $offset = ($page * $limit); + $query = "{$query} limit {$limit} offset {$offset}"; + } + + $rows = $wpdb->get_results($query); + + foreach($rows as $row) { + return new static($row); + } + + return null; + } //endregion } \ No newline at end of file diff --git a/classes/Storage/Driver/GoogleCloud/GoogleStorage.php b/classes/Storage/Driver/GoogleCloud/GoogleStorage.php index 7d39f71e..e6da6c6d 100755 --- a/classes/Storage/Driver/GoogleCloud/GoogleStorage.php +++ b/classes/Storage/Driver/GoogleCloud/GoogleStorage.php @@ -599,7 +599,7 @@ public function url($key, $type = null) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - if ($this->usesSignedURLs($type)) { + if (($type !== 'skip') && $this->usesSignedURLs($type)) { $expiration = $this->signedURLExpirationForType($type); return $this->presignedUrl($key, $expiration); } @@ -641,7 +641,7 @@ public function uploadUrl($key, $acl, $mimeType=null, $cacheControl = null, $exp } public function enqueueUploaderScripts() { - wp_enqueue_script('ilab-media-direct-upload-google', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-google.js', [], false, true); + wp_enqueue_script('ilab-media-direct-upload-google', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-google.js', [], MEDIA_CLOUD_VERSION, true); } //endregion diff --git a/classes/Storage/Driver/S3/DigitalOceanStorage.php b/classes/Storage/Driver/S3/DigitalOceanStorage.php index 164a5239..dc7c54be 100755 --- a/classes/Storage/Driver/S3/DigitalOceanStorage.php +++ b/classes/Storage/Driver/S3/DigitalOceanStorage.php @@ -73,7 +73,7 @@ public static function settingsErrorOptionName() { //region Direct Uploads public function enqueueUploaderScripts() { - wp_enqueue_script('ilab-media-direct-upload-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-s3.js', [], false, true); + wp_enqueue_script('ilab-media-direct-upload-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-s3.js', [], MEDIA_CLOUD_VERSION, true); } //endregion diff --git a/classes/Storage/Driver/S3/OtherS3Storage.php b/classes/Storage/Driver/S3/OtherS3Storage.php index c2cafedf..54a9da64 100755 --- a/classes/Storage/Driver/S3/OtherS3Storage.php +++ b/classes/Storage/Driver/S3/OtherS3Storage.php @@ -125,7 +125,7 @@ public function info( $key ) { //region Direct Uploads public function enqueueUploaderScripts() { - wp_enqueue_script('ilab-media-direct-upload-other-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-other-s3.js', [], false, true); + wp_enqueue_script('ilab-media-direct-upload-other-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-other-s3.js', [], MEDIA_CLOUD_VERSION, true); } //endregion diff --git a/classes/Storage/Driver/S3/S3Storage.php b/classes/Storage/Driver/S3/S3Storage.php index f86c196d..dacc04ff 100755 --- a/classes/Storage/Driver/S3/S3Storage.php +++ b/classes/Storage/Driver/S3/S3Storage.php @@ -17,10 +17,12 @@ namespace ILAB\MediaCloud\Storage\Driver\S3; use FasterImage\FasterImage; +use ILAB\MediaCloud\Storage\Driver\GoogleCloud\GoogleStorageSettings; use ILAB\MediaCloud\Storage\FileInfo; use ILAB\MediaCloud\Storage\InvalidStorageSettingsException; use ILAB\MediaCloud\Storage\StorageException; use ILAB\MediaCloud\Storage\StorageFile; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Storage\StorageManager; use function ILAB\MediaCloud\Utilities\anyNull; use function ILAB\MediaCloud\Utilities\arrayPath; @@ -31,6 +33,7 @@ use ILAB\MediaCloud\Wizard\ConfiguresWizard; use ILAB\MediaCloud\Wizard\StorageWizardTrait; use ILAB\MediaCloud\Wizard\WizardBuilder; +use ILABAmazon\CloudFront\CloudFrontClient; use ILABAmazon\Credentials\CredentialProvider; use ILABAmazon\Exception\AwsException; use ILABAmazon\Exception\CredentialsException; @@ -786,11 +789,44 @@ protected function presignedRequest($key, $expiration = 0) { } public function presignedUrl($key, $expiration = 0) { - $req = $this->presignedRequest($key, $expiration); - $uri = $req->getUri(); - $url = $uri->__toString(); + if ((StorageManager::driver() === 's3') && ($this->settings->validSignedCDNSettings())) { + if (empty($expiration)) { + $expiration = $this->settings->presignedURLExpiration; + } + + if (empty($expiration)) { + $expiration = 1; + } + + $cloudfrontClient = new CloudFrontClient([ + 'profile' => 'default', + 'version' => 'latest', + 'region' => $this->settings->region + ]); + + $srcUrl = $this->client->getObjectUrl($this->settings->bucket, $key); + $cdnHost = parse_url($this->settings->signedCDNURL, PHP_URL_HOST); + $srcHost = parse_url($srcUrl, PHP_URL_HOST); + $srcScheme = parse_url($srcUrl, PHP_URL_SCHEME); - return $url; + $srcUrl = str_replace($srcScheme, 'https', $srcUrl); + $srcUrl = str_replace($srcHost, $cdnHost, $srcUrl); + + $url = $cloudfrontClient->getSignedUrl([ + 'url' => $srcUrl, + 'expires' => time() + ($expiration * 60), + 'key_pair_id' => $this->settings->cloudfrontKeyID, + 'private_key' => $this->settings->cloudfrontPrivateKey + ]); + + return $url; + } else { + $req = $this->presignedRequest($key, $expiration); + $uri = $req->getUri(); + $url = $uri->__toString(); + + return $url; + } } public function url($key, $type = null) { @@ -798,7 +834,7 @@ public function url($key, $type = null) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - if ($this->usesSignedURLs($type)) { + if (($type !== 'skip') && $this->usesSignedURLs($type)) { $expiration = $this->signedURLExpirationForType($type); return $this->presignedUrl($key, $expiration); } else { @@ -848,7 +884,7 @@ public function uploadUrl($key, $acl, $mimeType = null, $cacheControl = null, $e } public function enqueueUploaderScripts() { - wp_enqueue_script('ilab-media-direct-upload-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-s3.js', [], false, true); + wp_enqueue_script('ilab-media-direct-upload-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-s3.js', [], MEDIA_CLOUD_VERSION, true); } //endregion diff --git a/classes/Storage/Driver/S3/S3StorageSettings.php b/classes/Storage/Driver/S3/S3StorageSettings.php index 80136936..387f33ee 100755 --- a/classes/Storage/Driver/S3/S3StorageSettings.php +++ b/classes/Storage/Driver/S3/S3StorageSettings.php @@ -20,6 +20,7 @@ use ILAB\MediaCloud\Storage\StorageManager; use ILAB\MediaCloud\Tools\ToolSettings; use ILAB\MediaCloud\Utilities\Environment; +use function ILAB\MediaCloud\Utilities\gen_uuid; /** * Class S3StorageSettings @@ -44,6 +45,9 @@ * @property int presignedURLExpirationForAudio * @property int presignedURLExpirationForDocs * @property bool settingsError + * @property string signedCDNURL + * @property string cloudfrontKeyID + * @property-read string cloudfrontPrivateKey * */ class S3StorageSettings extends ToolSettings { @@ -68,6 +72,8 @@ class S3StorageSettings extends ToolSettings { 'usePresignedURLsForDocs' => ['mcloud-storage-use-presigned-urls-docs', null, false], 'presignedURLExpirationForDocs' => ['mcloud-storage-presigned-expiration-docs', null, 0], 'settingsError' => ['ilab-backblaze-settings-error', null, false], + 'signedCDNURL' => ['mcloud-storage-signed-cdn-base', null, false], + 'cloudfrontKeyID' => ['mcloud-storage-cloudfront-key-id', null, false], ]; /** @var S3StorageInterface */ @@ -77,6 +83,12 @@ class S3StorageSettings extends ToolSettings { private $_pathStyleEndpoint = null; private $_region = null; private $_settingsError = null; + private $_cloudfrontPrivateKey = null; + + private $deletePrivateKey = false; + + /** @var callable */ + private $dieHandler = null; /** * S3StorageSettings constructor. @@ -85,6 +97,13 @@ class S3StorageSettings extends ToolSettings { */ public function __construct($storage) { $this->storage = $storage; + + add_filter('wp_die_ajax_handler', [$this, 'hookDieHandler']); + add_filter('wp_die_json_handler', [$this, 'hookDieHandler']); + add_filter('wp_die_jsonp_handler', [$this, 'hookDieHandler']); + add_filter('wp_die_xmlrpc_handler', [$this, 'hookDieHandler']); + add_filter('wp_die_xml_handler', [$this, 'hookDieHandler']); + add_filter('wp_die_handler', [$this, 'hookDieHandler']); } public function __get($name) { @@ -160,6 +179,29 @@ public function __get($name) { $storageClass = get_class($this->storage); $this->_settingsError = Environment::Option($storageClass::settingsErrorOptionName(), null, false); return $this->_settingsError; + } else if ($name === 'cloudfrontPrivateKey') { + if ($this->_cloudfrontPrivateKey !== null) { + return $this->_cloudfrontPrivateKey; + } + + $keyTemp = tempnam('/tmp', gen_uuid(8)); + + $keyFile = Environment::Option('mcloud-storage-cloudfront-private-key-file', null, null); + if (!empty($keyFile) && file_exists($keyFile)) { + $this->deletePrivateKey = false; + $this->_cloudfrontPrivateKey = $keyFile; + } + + if (empty($this->_cloudfrontPrivateKey)) { + $keyContents = Environment::Option('mcloud-storage-cloudfront-private-key'); + if (!empty($keyContents)) { + $this->deletePrivateKey = true; + file_put_contents($keyTemp, $keyContents); + $this->_cloudfrontPrivateKey = $keyTemp; + } + } + + return $this->_cloudfrontPrivateKey; } return parent::__get($name); @@ -180,11 +222,28 @@ public function __set($name, $value) { } public function __isset($name) { - if (in_array($name, ['region', 'endPointPathStyle', 'endpoint', 'settingsError'])) { + if (in_array($name, ['region', 'endPointPathStyle', 'endpoint', 'settingsError', 'cloudfrontPrivateKey'])) { return true; } return parent::__isset($name); } + public function validSignedCDNSettings() { + return (!empty($this->signedCDNURL) && !empty($this->cloudfrontKeyID) && !empty($this->cloudfrontPrivateKey)); + } + + public function hookDieHandler($handler) { + $this->dieHandler = $handler; + return [$this, 'deletePrivateKey']; + } + + public function deletePrivateKey($message, $title = '', $args = array()) { + if ($this->deletePrivateKey && file_exists($this->_cloudfrontPrivateKey)) { + unlink($this->_cloudfrontPrivateKey); + } + + call_user_func( $this->dieHandler, $message, $title, $args ); + } + } \ No newline at end of file diff --git a/classes/Storage/Driver/S3/WasabiStorage.php b/classes/Storage/Driver/S3/WasabiStorage.php index 25f301ae..04db128a 100755 --- a/classes/Storage/Driver/S3/WasabiStorage.php +++ b/classes/Storage/Driver/S3/WasabiStorage.php @@ -160,7 +160,7 @@ public function uploadUrl($key, $acl, $mimeType = null, $cacheControl = null, $e } public function enqueueUploaderScripts() { - wp_enqueue_script('ilab-media-upload-other-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-other-s3.js', [], false, true); + wp_enqueue_script('ilab-media-upload-other-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-other-s3.js', [], MEDIA_CLOUD_VERSION, true); } //endregion diff --git a/classes/Storage/StorageGlobals.php b/classes/Storage/StorageGlobals.php index 3ae58482..dc292062 100755 --- a/classes/Storage/StorageGlobals.php +++ b/classes/Storage/StorageGlobals.php @@ -76,6 +76,9 @@ final class StorageGlobals { /** @var string|null */ private $cdn = null; + /** @var string|null */ + private $signedCDN = null; + /** @var bool */ private $deleteOnUpload = false; @@ -97,7 +100,7 @@ final class StorageGlobals { private function __construct() { $this->deleteOnUpload = Environment::Option('mcloud-storage-delete-uploads', null, false); $this->deleteFromStorage = Environment::Option('mcloud-storage-delete-from-server', null, false); - $this->queuedDeletes = Environment::Option('mcloud-storage-queue-deletes', null, true); + $this->queuedDeletes = Environment::Option('mcloud-storage-queue-deletes', null, false); $this->prefixFormat = Environment::Option('mcloud-storage-prefix', ''); $this->subsitePrefixFormat = Environment::Option('mcloud-storage-subsite-prefixes', '', []); @@ -151,6 +154,11 @@ private function __construct() { $this->cdn = rtrim($this->cdn, '/'); } + $this->signedCDN = Environment::Option('mcloud-storage-signed-cdn-base', null, null); + if($this->signedCDN) { + $this->signedCDN = rtrim($this->signedCDN, '/'); + } + $this->docCdn = Environment::Option('mcloud-storage-doc-cdn-base', 'ILAB_AWS_S3_DOC_CDN_BASE', $this->cdn); $this->cacheControl = Environment::Option('mcloud-storage-cache-control', 'ILAB_AWS_S3_CACHE_CONTROL'); @@ -326,6 +334,11 @@ public static function cdn() { return self::instance()->cdn; } + /** @return string|null */ + public static function signedCDN() { + return self::instance()->signedCDN; + } + /** @return bool */ public static function deleteOnUpload() { return self::instance()->deleteOnUpload; diff --git a/classes/Tasks/Task.php b/classes/Tasks/Task.php index 430c546d..7c921b32 100755 --- a/classes/Tasks/Task.php +++ b/classes/Tasks/Task.php @@ -14,6 +14,7 @@ namespace ILAB\MediaCloud\Tasks; use Carbon\Carbon; +use ILAB\MediaCloud\Model\Model; use function ILAB\MediaCloud\Utilities\gen_uuid; use ILAB\MediaCloud\Utilities\Logging\Logger; use function ILAB\MediaCloud\Utilities\phpMemoryLimit; diff --git a/classes/Tasks/TaskData.php b/classes/Tasks/TaskData.php index 8ce1d3bb..0a35868f 100755 --- a/classes/Tasks/TaskData.php +++ b/classes/Tasks/TaskData.php @@ -13,6 +13,7 @@ namespace ILAB\MediaCloud\Tasks; +use ILAB\MediaCloud\Model\Model; use function ILAB\MediaCloud\Utilities\arrayPath; use ILAB\MediaCloud\Utilities\Logging\Logger; diff --git a/classes/Tasks/TaskRunner.php b/classes/Tasks/TaskRunner.php index 582fd475..729801d3 100755 --- a/classes/Tasks/TaskRunner.php +++ b/classes/Tasks/TaskRunner.php @@ -268,7 +268,7 @@ public static function dispatch($task) { Logger::info("Loop #{$loops}!"); } - if ($loops == 21) { + if ($loops == 2) { break; } diff --git a/classes/Tasks/TaskSchedule.php b/classes/Tasks/TaskSchedule.php index 647b341c..31317edb 100755 --- a/classes/Tasks/TaskSchedule.php +++ b/classes/Tasks/TaskSchedule.php @@ -15,6 +15,7 @@ use Carbon\Carbon; use Cron\CronExpression; +use ILAB\MediaCloud\Model\Model; use function ILAB\MediaCloud\Utilities\gen_uuid; use Lorisleiva\CronTranslator\CronParsingException; use Lorisleiva\CronTranslator\CronTranslator; diff --git a/classes/Tools/BatchProcessing/BatchProcessingTool.php b/classes/Tools/BatchProcessing/BatchProcessingTool.php index 6c7a704a..b16dfdc0 100755 --- a/classes/Tools/BatchProcessing/BatchProcessingTool.php +++ b/classes/Tools/BatchProcessing/BatchProcessingTool.php @@ -39,5 +39,9 @@ public function envEnabled() { return true; } + public function alwaysEnabled() { + return true; + } + //endregion } \ No newline at end of file diff --git a/classes/Tools/Crop/CropTool.php b/classes/Tools/Crop/CropTool.php index bf770da8..f520fa80 100755 --- a/classes/Tools/Crop/CropTool.php +++ b/classes/Tools/Crop/CropTool.php @@ -98,8 +98,8 @@ public function enqueueTheGoods($hook) wp_enqueue_style( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' ); - wp_enqueue_script ( 'ilab-modal-js', ILAB_PUB_JS_URL. '/ilab-modal.js', ['jquery'], false, true ); - wp_enqueue_script ( 'ilab-media-tools-js', ILAB_PUB_JS_URL. '/ilab-media-tools.js', ['jquery'], false, true ); + wp_enqueue_script ( 'ilab-modal-js', ILAB_PUB_JS_URL. '/ilab-modal.js', ['jquery'], MEDIA_CLOUD_VERSION, true ); + wp_enqueue_script ( 'ilab-media-tools-js', ILAB_PUB_JS_URL. '/ilab-media-tools.js', ['jquery'], MEDIA_CLOUD_VERSION, true ); } /** diff --git a/classes/Tools/DynamicImages/DynamicImagesTool.php b/classes/Tools/DynamicImages/DynamicImagesTool.php index 87d75fa0..30324156 100755 --- a/classes/Tools/DynamicImages/DynamicImagesTool.php +++ b/classes/Tools/DynamicImages/DynamicImagesTool.php @@ -372,8 +372,8 @@ public function enqueueTheGoods($hook) { wp_enqueue_style('wp-color-picker'); wp_enqueue_script('wp-pointer'); wp_enqueue_script('wp-color-picker'); - wp_enqueue_script('ilab-modal-js', ILAB_PUB_JS_URL.'/ilab-modal.js', ['jquery'], false, true); - wp_enqueue_script('ilab-media-tools-js', ILAB_PUB_JS_URL.'/ilab-media-tools.js', ['ilab-modal-js'], false, true); + wp_enqueue_script('ilab-modal-js', ILAB_PUB_JS_URL.'/ilab-modal.js', ['jquery'], MEDIA_CLOUD_VERSION, true); + wp_enqueue_script('ilab-media-tools-js', ILAB_PUB_JS_URL.'/ilab-media-tools.js', ['ilab-modal-js'], MEDIA_CLOUD_VERSION, true); } /** diff --git a/classes/Tools/Permissions/OptInTool.php b/classes/Tools/Permissions/OptInTool.php index 95303c1c..5302985e 100755 --- a/classes/Tools/Permissions/OptInTool.php +++ b/classes/Tools/Permissions/OptInTool.php @@ -39,5 +39,9 @@ public function envEnabled() { return true; } + public function alwaysEnabled() { + return true; + } + //endregion } \ No newline at end of file diff --git a/classes/Tools/Storage/StorageTool.php b/classes/Tools/Storage/StorageTool.php index db941a09..2a1bda8f 100755 --- a/classes/Tools/Storage/StorageTool.php +++ b/classes/Tools/Storage/StorageTool.php @@ -348,7 +348,10 @@ function ( $file, $type, $fullsize ) { $addFilter = apply_filters( 'media-cloud/storage/add-upload-filter', $addFilter ); if ( $addFilter ) { - add_filter( 'upload_dir', [ $this, 'getUploadDir' ], 1000 ); + add_filter( 'upload_dir', function ( $uploads ) use( $file ) { + $mimeType = arrayPath( $file, 'type', null ); + return $this->getUploadDir( $uploads, $mimeType ); + }, 1000 ); } return $file; }, 1000 ); @@ -416,13 +419,13 @@ function ( $file, $type, $fullsize ) { add_filter( 'the_content', [ $this, 'filterContent' ], - PHP_INT_MAX, + PHP_INT_MAX - 1, 1 ); add_filter( 'render_block', [ $this, 'filterBlocks' ], - PHP_INT_MAX, + PHP_INT_MAX - 1, 2 ); add_filter( @@ -912,9 +915,10 @@ public function deleteAttachment( $id ) * Filters the uploads directory data. (https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/functions.php#L1880) * * @param array $uploads + * @param string|null $type * @return array */ - public function getUploadDir( $uploads ) + public function getUploadDir( $uploads, $type = null ) { global $job_manager_upload, $job_manager_uploading_file ; if ( !empty($job_manager_upload) && !empty($job_manager_uploading_file) ) { @@ -923,7 +927,14 @@ public function getUploadDir( $uploads ) if ( empty(StorageGlobals::prefixFormat()) ) { return $uploads; } + $lastType = Prefixer::currentType(); + if ( !empty($type) ) { + Prefixer::setType( $type ); + } $prefix = trim( StorageGlobals::prefix( null ), '/' ); + if ( !empty($type) ) { + Prefixer::setType( $lastType ); + } if ( is_multisite() && !is_main_site() ) { @@ -1601,14 +1612,20 @@ public function getAttachmentURLFromMeta( $meta ) if ( $this->client->usesSignedURLs( $type ) ) { $url = $this->client->url( $meta['s3']['key'], $type ); - if ( !empty(StorageGlobals::cdn()) ) { - $cdnScheme = parse_url( StorageGlobals::cdn(), PHP_URL_SCHEME ); - $cdnHost = parse_url( StorageGlobals::cdn(), PHP_URL_HOST ); - $urlScheme = parse_url( $url, PHP_URL_SCHEME ); - $urlHost = parse_url( $url, PHP_URL_HOST ); - return str_replace( "{$urlScheme}://{$urlHost}", "{$cdnScheme}://{$cdnHost}", $url ); - } else { + if ( StorageManager::driver() === 's3' && !empty(StorageGlobals::signedCDN()) ) { return $url; + } else { + + if ( !empty(StorageGlobals::cdn()) ) { + $cdnScheme = parse_url( StorageGlobals::cdn(), PHP_URL_SCHEME ); + $cdnHost = parse_url( StorageGlobals::cdn(), PHP_URL_HOST ); + $urlScheme = parse_url( $url, PHP_URL_SCHEME ); + $urlHost = parse_url( $url, PHP_URL_HOST ); + return str_replace( "{$urlScheme}://{$urlHost}", "{$cdnScheme}://{$cdnHost}", $url ); + } else { + return $url; + } + } } else { @@ -3065,7 +3082,7 @@ private function hookAttachmentDetails() 'ilab-media-grid-js', ILAB_PUB_JS_URL . '/ilab-media-grid.js', [ 'jquery' ], - false, + MEDIA_CLOUD_VERSION, true ); } ); @@ -3263,7 +3280,7 @@ private function hookMediaGrid() display: none; position: absolute; right: 5px; - bottom: 4px; + bottom: 5px; z-index: 5; } @@ -3274,6 +3291,8 @@ private function hookMediaGrid() + + @endtrack diff --git a/views/tasks/batch-info.blade.php b/views/tasks/batch-info.blade.php index 34d2ff9f..8395f66c 100755 --- a/views/tasks/batch-info.blade.php +++ b/views/tasks/batch-info.blade.php @@ -46,7 +46,7 @@ @elseif($option['type'] == 'browser') @elseif($option['type'] == 'media-select') -