Skip to content

Commit

Permalink
* Added new option to imgix to disable urlencode() the filename whi…
Browse files Browse the repository at this point in the history
…ch may cause issues for certain unicode characters in filenames. If imgix is working fine for you, you should not turn this on.

* Fixed missing regions in the setup wizard for Wasabi
  • Loading branch information
jawngee committed Mar 8, 2022
1 parent 5b0b334 commit d879b33
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 13 deletions.
9 changes: 6 additions & 3 deletions classes/Tools/Imgix/ImgixTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ public function buildSizedImage($id, $size) {
$imageFile = (isset($meta['s3'])) ? $meta['s3']['key'] : $meta['file'];
}

$doNotUrlEncode = apply_filters('media-cloud/dynamic-images/do-not-url-encode', $this->settings->doNotUrlEncode);
$result = [
$imgix->createURL(str_replace(['%2F', '%2540', '%40'], ['/', '@', '@'], urlencode($imageFile)), $params),
$imgix->createURL(str_replace(['%2F', '%2540', '%40'], ['/', '@', '@'], $doNotUrlEncode ? $imageFile : urlencode($imageFile)), $params),
$size[0],
$size[1]
];
Expand Down Expand Up @@ -499,8 +500,9 @@ public function buildImage($id, $size, $params = null, $skipParams = false, $mer
}


$doNotUrlEncode = apply_filters('media-cloud/dynamic-images/do-not-url-encode', $this->settings->doNotUrlEncode);
$result = [
$imgix->createURL(str_replace(['%2F', '%2540', '%40'], ['/', '@', '@'], urlencode($imageFile)), ($skipParams) ? [] : $params),
$imgix->createURL(str_replace(['%2F', '%2540', '%40'], ['/', '@', '@'], $doNotUrlEncode ? $imageFile : urlencode($imageFile)), ($skipParams) ? [] : $params),
$meta['width'],
$meta['height'],
false
Expand Down Expand Up @@ -753,7 +755,8 @@ public function urlForStorageMedia($key, $params = []) {
$imgix->setIncludeLibraryParam(false);
}

return $imgix->createURL(str_replace(['%2F', '%2540', '%40'], ['/', '@', '@'], urlencode($key)), $params);
$doNotUrlEncode = apply_filters('media-cloud/dynamic-images/do-not-url-encode', $this->settings->doNotUrlEncode);
return $imgix->createURL(str_replace(['%2F', '%2540', '%40'], ['/', '@', '@'], $doNotUrlEncode ? $key : urlencode($key)), $params);
}

public function fixCleanedUrls($good_protocol_url, $original_url, $context) {
Expand Down
4 changes: 3 additions & 1 deletion classes/Tools/Imgix/ImgixToolSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @property bool removeQueryVars
* @property ?string cropMode
* @property ?string cropPosition
* @property bool doNotUrlEncode
*/
class ImgixToolSettings extends DynamicImagesToolSettings {
private $_imgixDomains = null;
Expand All @@ -56,6 +57,7 @@ class ImgixToolSettings extends DynamicImagesToolSettings {
'removeQueryVars' => ['mcloud-imgix-remove-extra-variables', null, false],
'cropMode' => ['mcloud-imgix-crop-mode', null, null],
'cropPosition' => ['mcloud-imgix-crop-position', null, 'center'],
'doNotUrlEncode' => ['mcloud-imgix-do-not-urlencode', null, false],
];

public function __construct() {
Expand Down Expand Up @@ -130,7 +132,7 @@ public function __set($name, $value) {
}

public function __isset($name) {
if (in_array($name, ['imgixDomains', 'noGifSizes', 'keepThumbnails'])) {
if (in_array($name, ['imgixDomains', 'noGifSizes', 'keepThumbnails', 'doNotUrlEncode'])) {
return true;
}

Expand Down
7 changes: 6 additions & 1 deletion classes/Tools/Storage/Driver/S3/WasabiStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ public static function configureWizard($builder = null) {
'us-east-1' => 'US East 1',
'us-east-2' => 'US East 2',
'us-west-1' => 'US West',
'eu-central-1' => 'EU'
'us-central' => 'US Central',
'eu-central-1' => 'EU (Amsterdam)',
'eu-west-1' => 'EU (London)',
'eu-west-2' => 'EU (Paris)',
'ap-northeast-1' => 'Asia Pacific (Tokyo)',
'ap-northeast-2' => 'Asia Pacific (Osaka)',
])
->endStep()
->testStep('wizard.cloud-storage.providers.wasabi.test', 'Test Settings', 'Perform tests to insure that your cloud storage provider is configured correctly.', false);
Expand Down
7 changes: 4 additions & 3 deletions composer.library.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
],
"config": {
"platform": {
"php": "7.1"
"php": "7.4"
}
},
"require" : {
"php": ">=7.1",
"php": ">=7.4",
"duncan3dc/blade": ">=3.3",
"duncan3dc/object-intruder": "*",
"fasterimage/fasterimage": ">=1.1",
Expand All @@ -44,6 +44,7 @@
"muxinc/mux-php": ">=0.4.0",
"ivopetkov/html5-dom-document-php": ">=2.2",
"dragonmantank/cron-expression": ">=2.3",
"lorisleiva/cron-translator": ">=0.1.0"
"lorisleiva/cron-translator": ">=0.1.0",
"symfony/http-kernel": "*"
}
}
6 changes: 6 additions & 0 deletions config/imgix.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@
"description" => "Removes extra query variables from the imgix URL such as the <code>ixlib</code> and <code>wpsize</code> variables.",
"type" => "checkbox",
"default" => false
],
"mcloud-imgix-do-not-urlencode" => [
"title" => "Do Not URL Encode File Names",
"description" => "Disables URL encoding file names, which may improve compatibility for certain unicode characters.",
"type" => "checkbox",
"default" => false
]
]
],
Expand Down
4 changes: 2 additions & 2 deletions ilab-media-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Version: 4.3.8
Version: 4.3.11
Requires PHP: 7.4
Author URI: http://interfacelab.io
*/
Expand Down Expand Up @@ -95,7 +95,7 @@
}

// Version Defines
define( 'MEDIA_CLOUD_VERSION', '4.3.8' );
define( 'MEDIA_CLOUD_VERSION', '4.3.11' );
define( 'MEDIA_CLOUD_INFO_VERSION', '4.0.2' );
define( 'MCLOUD_IS_BETA', false );
// Directory defines
Expand Down
4 changes: 2 additions & 2 deletions lib/mcloud-wp-media/imagify-php/class-imagify.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public function optimize( $image, $options = array() ) {
$data = array(
'image' => curl_file_create( $image ),
'data' => json_encode(
array(
(object)array(
'aggressive' => ( 'aggressive' === $options['level'] ) ? true : false,
'ultra' => ( 'ultra' === $options['level'] ) ? true : false,
'resize' => $options['resize'],
'resize' => (object)$options['resize'],
'keep_exif' => $options['keep_exif'],
)
)
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Requires at least: 4.9
Tested up to: 5.9.1
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Stable tag: 4.3.8
Stable tag: 4.3.11
Requires PHP: 7.4

Automatically store media on Amazon S3, Google Cloud Storage, DigitalOcean Spaces + others. Serve CSS/JS assets through CDNs. Integrate with Imgix.
Expand Down Expand Up @@ -105,6 +105,15 @@ Imgix is a content delivery network with a twist. In addition to distributing y

== Changelog ==

= 4.3.11 - 3/8/2022 =

* Added new option to imgix to disable `urlencode()` the filename which may cause issues for certain unicode characters in filenames. If imgix is working fine for you, you should not turn this on.
* Fixed missing regions in the setup wizard for Wasabi

= 4.3.9 - 3/4/2022 =

* Fixed Imagify API integration.

= 4.3.8 - 3/2/2022 =

* Update to latest AWS SDK. Fixes critical issue where deleting items from cloud storage would fail due to a bug in the SDK. If you are using S3 or S3 compatible storage, you need to upgrade to this.
Expand Down

0 comments on commit d879b33

Please sign in to comment.