Skip to content

Commit

Permalink
Pass width & height to upload_image
Browse files Browse the repository at this point in the history
  • Loading branch information
Twansparant committed Dec 22, 2023
1 parent 8c6f6eb commit 1403f09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/class-process.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public static function process_resize_request($id, $quality, $width, $height, $c
do_action('responsive_pics_file_saved_local', $id, $saved_file);

if (class_exists('Amazon_S3_And_CloudFront')) {
ResponsivePics()->s3offload->upload_image($id, $saved_file);
ResponsivePics()->s3offload->upload_image($id, $saved_file, round($width * $ratio), round($height * $ratio));
}
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/class-s3-offload.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct() {
/**
* Upload to S3 storage
*/
public static function upload_image($id, $file = null) {
public static function upload_image($id, $file = null, $width = null, $height = null) {
global $as3cf;

$s3_upload = null;
Expand All @@ -28,7 +28,7 @@ public static function upload_image($id, $file = null) {
Media_Library_Item::init_cache();
$as3cf_item = Media_Library_Item::get_by_source_id($id);

$size = $file['width'] .'x'. $file['height'];
$size = $width .'x'. $height;
$source_file = $file['file'];

if ($as3cf_item) {
Expand Down Expand Up @@ -131,7 +131,7 @@ public static function file_exists($id, $file) {
$height = (int) $file['height'];

// Calculate size
$size = ($width * $ratio) .'x'. ($height * $ratio);
$size = round($width * $ratio) .'x'. round($height * $ratio);
$as3cf_objects = $as3cf_item ? $as3cf_item->objects() : null;
$size_exists = $as3cf_objects ? array_key_exists($size, $as3cf_objects) : false;
$file_exists = $size_exists ? ($file['file'] === $as3cf_objects[$size]['source_file']) : false;
Expand Down

0 comments on commit 1403f09

Please sign in to comment.