diff --git a/bu-media-s3.php b/bu-media-s3.php index 6876f6d..1e1469b 100644 --- a/bu-media-s3.php +++ b/bu-media-s3.php @@ -3,7 +3,7 @@ * Plugin Name: bu-media-s3 * Plugin URI: https://github.com/bu-ist/bu-media-s3 * Description: A plugin for integrating S3 with WordPress - * Version: 0.1 + * Version: 1.0.0 * Author: Boston University * Author URI: https://developer.bu.edu/ * @@ -15,6 +15,7 @@ require_once dirname( __FILE__ ) . '/src/s3-assets.php'; require_once dirname( __FILE__ ) . '/src/filters.php'; +// Load the WP-CLI commands if we're running in a CLI environment. if ( defined( 'WP_CLI' ) && WP_CLI ) { require_once dirname( __FILE__ ) . '/src/wp-cli-commands.php'; } diff --git a/package-lock.json b/package-lock.json index 4921b37..0741382 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bu-media-s3", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 6eac4f5..0c3261c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bu-media-s3", - "version": "0.1.0", + "version": "1.0.0", "description": "Integrations between WordPress and AWS S3", "main": "index.js", "scripts": { diff --git a/readme.md b/readme.md index 35cce17..326a6c6 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ BU Media S3 is a WordPress plugin designed to work with the [Human Made S3 Uploa - **S3 Upload Directory**: The plugin filters the `upload_dir` hook and rewrites the values in a way that is compatible with the S3 Uploads plugin and the BU Protected S3 Object Lambda stack, redirecting all media uploads to the S3 bucket. It also changes the default upload location from `wp-content/uploads` to `files`, which is the convention for BU WordPress sites. -- **Prevent Image Scaling**: By default, WordPress generates a scaled derivative for every image size that is defined for the current site. Because the BU Protected S3 Object Lambda stack handles image resizing automatically, the WordPress media library only needs to handle the full sized original upload. This plugin tells WordPress not to generate any derivative sizes on upload. +- **Prevent Image Scaling**: By default, WordPress generates a scaled derivative for every image size that is defined for the current site. Because the BU Protected S3 Object Lambda stack handles image resizing automatically, the WordPress media library only needs to handle the full sized original upload. This plugin tells WordPress not to generate any derivative sizes on upload. It preserves the attachment metadata for all of the defined sizes by generating it directly during the upload process. - **Suppress Big Image Threshold Resizing**: WordPress 5.3 introduced a new feature that automatically resizes images for "web-ready" dimensions. This plugin suppresses this feature, allowing you to upload images at their full size. diff --git a/src/filters.php b/src/filters.php index 5729770..e06e954 100644 --- a/src/filters.php +++ b/src/filters.php @@ -1,6 +1,16 @@ $size_data ) { + // Calcualte the new filename by adding the size to the original filename using the WordPress convention. + $new_filename = $pathinfo['filename'] . '-' . $size_data['width'] . 'x' . $size_data['height'] . '.' . $pathinfo['extension']; + + // Add the new size to the metadata. + $metadata['sizes'][ $size ] = array( + 'file' => $new_filename, + 'width' => $size_data['width'], + 'height' => $size_data['height'], + 'mime-type' => $mime_type, + ); + } + return $metadata; +} + // Disable the big image threshold, we don't want WordPress to do any resizing at all. add_filter( 'big_image_size_threshold', '__return_false' );