Skip to content

Commit

Permalink
* Added beta support for Bunny CDN as a storage provider.
Browse files Browse the repository at this point in the history
    * Note that Bunny CDN doesn't support ACLs so it can't do signed URLs like other cloud storage providers, so it is not suitable for WooCommerce, EDD or anything else where you want to protect individual files.
    * You can protect directories though and any files in a specified directory will be signed.  This is probably a moving target  feature wise.
    * Also note that this works differently then Bunny's WordPress plugin.  Bunny's plugin works via pull where Media Cloud is  push (it uploads your media to Bunny CDN).  Which way is better is up to you to decide, though you can't use Bunny's plugin in a dev environment or on a localhost during dev.
* Added documentation for Bunny CDN
* Fixed Migrate to Mux task.
* Migrating media now migrates .webp and .avif files regardless of what plugin generated them.
* Fixes for some PHP 8.2 errors and notices.
  • Loading branch information
jawngee committed Mar 22, 2024
1 parent 4cf30db commit b2bb4ca
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public static function configureWizard($builder = null) {
$builder
->tutorialSection('cloud-storage-bunnycdn-tutorial', true)
->tutorial('wizard.cloud-storage.providers.bunnycdn.tutorial.step-1', 'Create Storage Zone', 'Create the storage zone you will be using with Media Cloud.')
->tutorial('wizard.cloud-storage.providers.bunnycdn.tutorial.step-2', 'Create Pull Zone', 'Create a pull zone for your storage zone. It\'s a lot of zones.', null, true)
->tutorial('wizard.cloud-storage.providers.bunnycdn.tutorial.step-2', 'Add a Pull Zone', 'Create a pull zone for your storage zone.', null, true)
->endSection();

return $builder;
Expand Down
19 changes: 0 additions & 19 deletions classes/Tools/Storage/StorageTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,6 @@ public function processFile(
);
}

$webpKey = null;
$extraFiles = [];
$extraFormats = [];
$additionalPaths = apply_filters(
Expand All @@ -2511,25 +2510,15 @@ public function processFile(
'path' => $webpPath,
'key' => $webpKey,
];
// if (!$this->client->exists($webpKey)) {
// Logger::info("\tUploading $filename .webp version to S3", [], __METHOD__, __LINE__);
// $this->client->upload($webpKey, $webpPath, $privacy, StorageToolSettings::cacheControl(), StorageToolSettings::expires(), 'image/webp');
// $canDelete = apply_filters('media-cloud/storage/delete_uploads', true);
// if (!empty($canDelete) && StorageToolSettings::deleteOnUpload()) {
// $this->deleteCache[] = $webpPath;
// }
// }
}


if ( $uploadType === 'image' ) {
Logger::info( "Testing for webp and avif for {$filename}" );
$parsed = pathinfo( $filename );
$webP = $parsed['dirname'] . '/' . $parsed['filename'] . '.webp';
$webPBase = $parsed['dirname'] . '/' . $parsed['basename'] . '.webp';
$avif = $parsed['dirname'] . '/' . $parsed['filename'] . '.avif';
$avifBase = $parsed['dirname'] . '/' . $parsed['basename'] . '.avif';
Logger::info( "Looking for " . $upload_path . '/' . $webP );

if ( file_exists( $upload_path . '/' . $webP ) ) {
Logger::info( "Found " . $upload_path . '/' . $webP );
Expand All @@ -2540,7 +2529,6 @@ public function processFile(
];
}

Logger::info( "Looking for " . $upload_path . '/' . $avif );

if ( file_exists( $upload_path . '/' . $avif ) ) {
Logger::info( "Found " . $upload_path . '/' . $avif );
Expand All @@ -2551,7 +2539,6 @@ public function processFile(
];
}

Logger::info( "Looking for " . $upload_path . '/' . $webPBase );

if ( file_exists( $upload_path . '/' . $webPBase ) ) {
Logger::info( "Found " . $upload_path . '/' . $webPBase );
Expand All @@ -2562,7 +2549,6 @@ public function processFile(
];
}

Logger::info( "Looking for " . $upload_path . '/' . $avifBase );

if ( file_exists( $upload_path . '/' . $avifBase ) ) {
Logger::info( "Found " . $upload_path . '/' . $avifBase );
Expand All @@ -2587,7 +2573,6 @@ public function processFile(

$extraKey = $extraFile['key'];
$extraPath = $extraFile['path'];
Logger::info( "Uploading {$extraKey} at {$extraPath}" );

if ( !$this->client->exists( $extraKey ) ) {
Logger::info(
Expand Down Expand Up @@ -2639,10 +2624,6 @@ public function processFile(
'options' => $options,
'formats' => $extraFormats,
];
Logger::info( "New data:" . json_encode( $extraFormats, JSON_PRETTY_PRINT ) );
// if (!empty($webpKey)) {
// $data['s3']['formats']['webp'] = $webpKey;
// }

if ( file_exists( $upload_path . '/' . $filename ) ) {
$ftype = wp_check_filetype( $upload_path . '/' . $filename );
Expand Down
5 changes: 1 addition & 4 deletions classes/Tools/Video/Driver/Mux/MuxHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ public function importUrl( $attachmentId, $meta, $doUpdate = true )
$url = $storageTool->client()->presignedUrl( $meta['s3']['key'], 30 );
} else {
$otherMeta = wp_get_attachment_metadata( $attachmentId, true );
Logger::info( "URL FOR IMPORT:" . json_encode( $otherMeta, JSON_PRETTY_PRINT ) );

if ( isset( $otherMeta['s3'] ) ) {
$url = $storageTool->client()->presignedUrl( $otherMeta['s3']['key'], 30 );
Expand All @@ -620,15 +619,13 @@ public function importUrl( $attachmentId, $meta, $doUpdate = true )
}

}

Logger::info( "URL FOR IMPORT:" . $url );

} else {
$url = wp_get_attachment_url( $attachmentId );
if ( defined( 'MEDIACLOUD_DEV_MODE' ) && defined( 'MEDIACLOUD_VIDEO_SERVER' ) && !empty(constant( 'MEDIACLOUD_VIDEO_SERVER' )) ) {
// DEBUG ONLY
$url = str_replace( home_url(), constant( 'MEDIACLOUD_VIDEO_SERVER' ), $url );
}
Logger::info( "URL FOR IMPORT 2:" . $url );
}

$input = new InputSettings( [
Expand Down
2 changes: 1 addition & 1 deletion config/storage.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
'help' => [
[ 'title' => 'Sign Up For Bunny CDN Account', 'url' => 'https://bunny.net?ref=33lsyjqfr3' ],
[ 'title' => 'Setup Wizard', 'wizard' => 'bunnycdn' ],
[ 'title' => 'Read Documentation', 'url' => 'https://docs.mediacloud.press/articles/documentation/cloud-storage/setting-up-digitalocean-spaces' ],
[ 'title' => 'Read Documentation', 'url' => 'https://docs.mediacloud.press/articles/documentation/cloud-storage/setting-up-bunny-cdn/' ],
]
],
'dreamhost' => [
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.6.0
Version: 4.6.1
Requires PHP: 7.4
Author URI: http://interfacelab.io
*/
Expand Down Expand Up @@ -117,7 +117,7 @@
define( 'WP_FS__ENABLE_GARBAGE_COLLECTOR', false );
}
// Version Defines
define( 'MEDIA_CLOUD_VERSION', '4.6.0' );
define( 'MEDIA_CLOUD_VERSION', '4.6.1' );
define( 'MEDIA_CLOUD_INFO_VERSION', '4.0.2' );
define( 'MCLOUD_IS_BETA', false );
// Debugging
Expand Down
8 changes: 4 additions & 4 deletions 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: 6.5
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Stable tag: 4.6.0
Stable tag: 4.6.1
Requires PHP: 7.4

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

== Changelog ==

= 4.6.0 - 03/212024 =
= 4.6.1 - 03/22/2024 =

* Migrating media now migrates .webp and .avif files regardless of what plugin generated them.
* Added beta support for Bunny CDN as a storage provider.
* Note that Bunny CDN doesn't support ACLs so it can't do signed URLs like other cloud storage providers, so it is not suitable for WooCommerce, EDD or anything else where you want to protect individual files.
* You can protect directories though and any files in a specified directory will be signed. This is probably a moving target feature wise.
* Also note that this works differently then Bunny's WordPress plugin. Bunny's plugin works via pull where Media Cloud is push (it uploads your media to Bunny CDN). Which way is better is up to you to decide, though you can't use Bunny's plugin in a dev environment or on a localhost during dev.
* Documentation is non existent at the moment but that will be remedied later next week.
* Added documentation for Bunny CDN
* Fixed Migrate to Mux task.
* Migrating media now migrates .webp and .avif files regardless of what plugin generated them.
* Fixes for some PHP 8.2 errors and notices.


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
<h1 id="setting-up-bunnycdn">Setting Up Bunny CDN</h1>
<h2 class='track-pos' id='step-1-create-bucket'>Step 1 &#8211; Create Storage Zone</h2>
<p>To get started...</p>
<p>Get started by logging into the Bunny CDN dashboard.&nbsp; If you don't have an account with Bunny CDN, you can <a href="https://bunny.net?ref=33lsyjqfr3" target="_blank" rel="noopener">create one here</a>.</p>
<p>Once in the dashboard, it should look something like this:</p>
<figure><a href="https://docs-media.s3.ap-southeast-1.amazonaws.com/0e352206-8817-4fdd-9268-5dd179e73b64.png" target="_blank" rel="noopener"><img src="https://docs-media.s3.ap-southeast-1.amazonaws.com/0e352206-8817-4fdd-9268-5dd179e73b64.png" alt="Step 1 - Bunny CDN Dashboard"></a></figure>
<p>Click on the <strong>Storage</strong> link on the left hand side (#1) and then click on <strong>Add Storage Zone</strong> (#2).&nbsp; When you click on that you'll be presented with this screen:</p>
<figure><a href="https://docs-media.s3.ap-southeast-1.amazonaws.com/ec6aebc0-60de-4c77-97e3-881e2be4a2b2.png" target="_blank" rel="noopener"><img src="https://docs-media.s3.ap-southeast-1.amazonaws.com/ec6aebc0-60de-4c77-97e3-881e2be4a2b2.png" alt="Step 2 - Create Storage Zone"></a></figure>
<p>In the&nbsp;<strong>Storage Zone Name</strong> field supply a name for your zone.&nbsp; You can use alphanumeric characters, dashes and underscores but no spaces.</p>
<p>Down a little further click on the <strong>Main Storage Region</strong>.&nbsp; This region should be closest to wherever your WordPress server is.</p>
<p>Next, you'll need to select one or more regions to replicate your data to.&nbsp; This step is optional but highly recommended.</p>
<p>Finally, scroll to the bottom of the page and click on the big orange&nbsp;<strong>Add Storage Zone</strong> button.</p>
<h3 class='track-pos' id='step-1a-get-api-key'>Get Your API Key</h3>
<p>After you've clicked that button, you'll be taken to your newly created storage zone's details page.</p>
<figure><a href="https://docs-media.s3.ap-southeast-1.amazonaws.com/0e2bab57-55c8-484b-8a65-a8c2221e7d3c.png" target="_blank" rel="noopener"><img src="https://docs-media.s3.ap-southeast-1.amazonaws.com/0e2bab57-55c8-484b-8a65-a8c2221e7d3c.png" alt="Step 2 - Get API Key"></a></figure>
<p>To get our API key, click on the&nbsp;<strong>FTP &amp; API Access</strong> link.&nbsp; Towards the bottom of that screen you'll see a section marked&nbsp;<strong>Password</strong>.&nbsp; Click on the copy icon next to the first entry marked&nbsp;<strong>Password.</strong>&nbsp; This is your API key.&nbsp; &nbsp;Store it somewhere safe until we set up Media Cloud further down the tutorial.</p>
<p>After you've saved your API key, we're going to need to create a pull zone.&nbsp; This is the CDN part of Bunny CDN.&nbsp; Click on the black&nbsp;<strong>Connect Pull Zone</strong> button in the upper right to move onto the next step.</p>
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
<h1 class='track-pos' id='step-2-create-application-key'>Step 2 &#8211; Create a Pull Zone</h1>
<p>...</p>
<h2 class='track-pos' id='step-2-add-a-pull-zone'>Step 2 &#8211; Add a Pull Zone</h2>
<p>When you click the&nbsp;<strong>Connect Pull Zone</strong> button you'll be presented with a pop-up dialog that looks like this:</p>
<figure><a href="https://docs-media.s3.ap-southeast-1.amazonaws.com/da8c3206-a2f6-4058-b462-e433a7091487.png" target="_blank" rel="noopener"><img src="https://docs-media.s3.ap-southeast-1.amazonaws.com/da8c3206-a2f6-4058-b462-e433a7091487.png" alt="Step 3a - Add Pull Zone"></a></figure>
<p>Simply click on the big orange button marked&nbsp;<strong>Add Pull Zone</strong>.&nbsp; That will take you to this page:</p>
<figure><a href="https://docs-media.s3.ap-southeast-1.amazonaws.com/db965cca-5f3d-4dcf-94ab-cc8babf7466c.png" target="_blank" rel="noopener"><img src="https://docs-media.s3.ap-southeast-1.amazonaws.com/db965cca-5f3d-4dcf-94ab-cc8babf7466c.png" alt="Step 3b - Add Pull Zone"></a></figure>
<p>On the add pull zone screen, enter in whatever name you want for the CDN domain. You can add your own domain later on, for now you'll want to use the XXXX.b-cdn.net domain that Bunny provides.</p>
<p>Make sure that&nbsp;<strong>Origin Type</strong> is set to&nbsp;<strong>Storage Zone</strong> and that&nbsp;<strong>Storage Zone</strong> is set to the storage zone we made in the first step.</p>
<p>Select any other options you want and then scroll to the bottom and click the big orange <strong>Add Pull Zone</strong> button.</p>
<h3 class='track-pos' id='step-2a-get-pull-zone-url'>Get Your Pull Zone URL</h3>
<p>After you've clicked&nbsp;<strong>Add Pull Zone</strong> and your pull zone has been created, you'll see this screen:</p>
<figure><a href="https://docs-media.s3.ap-southeast-1.amazonaws.com/ea3a75af-15c7-428c-853c-92d55d2c779e.png" target="_blank" rel="noopener"><img src="https://docs-media.s3.ap-southeast-1.amazonaws.com/ea3a75af-15c7-428c-853c-92d55d2c779e.png" alt="Step 4 Get Pull Zone URL"></a></figure>
<p>In the&nbsp;<strong>Linked Hostnames</strong> copy the domain name as we'll be using it in the next step.</p>

0 comments on commit b2bb4ca

Please sign in to comment.