Upfront resizing causing issues with Amazon S3 and CloudFront plugin

In an effort to improve scalability and speed, I have been using the free Amazon S3 and CloudFront plugin by Brad Touesnard. This plugin for the most part has worked flawlessly by uploading the image to my s3 account and then saving the path of the full image and all thumbnails in the word press post then deleting the local files after the files have been uploaded to amazon s3.

However it looks like upfront is having some issues that are causing image insertion and gallery insertion to fail.

Upon saving an image insertion upfront is attempting to resize the photo and re-save the image. However upfront is most likely attempting to do this with a local file path that doesn’t exist which is causing the failure. Its even being naughty and trying to resize the photo when only “original” size is selected on a single image embed.


1. Create a network admin toggle for the upfront theme that allows says: “allow for upfront resizing” if selected no then cropping of images would be disabled and thumnails would be used from the images already available.

2. When resizing perhaps use a different method that allows for remote urls that amazon s3 plugin is using that point to amazon s3. Below I will attach a code snippet on what functions to use to perform these actions.

  • Ben
    • The Incredible Smush
    // The file
    $filename = 'http://valplibrary.files.wordpress.com/2009/01/5b585d_merry-christmas-blue-style.jpg';
    $percent = 0.5; // percentage of resize

    // Content type
    header('Content-type: image/jpeg');

    // Get new dimensions
    list($width, $height) = getimagesize($filename);
    $new_width = $width * $percent;
    $new_height = $height * $percent;

    // Resample
    $image_p = imagecreatetruecolor($new_width, $new_height);
    $image = imagecreatefromjpeg($filename);
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    // Output
    imagejpeg($image_p, null, 100);

    (source: php.net)

  • Michael Bissett
    • Recruit

    Hey @ben, thanks for the suggestions here! :slight_smile:

    Providing an option to disabling the resizing of images would most likely be inside of the Upfront editor, rather than inside the network dashboard (especially considering not everyone runs a Multisite), but that still sounds like in interesting option.

    As for changing the logic… hmm. While a developer would have better insight on that topic, that might be a more complicated matter (the question of whether the code you supplied could be dropped into Upfront comes into my mind, I get the feeling that it’d require a good deal of adjustment).

    I’ve passed this thread along to our Upfront team, thanks again for the feedback! :slight_smile:

    Kind Regards,


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.