S3-Uploads icon indicating copy to clipboard operation
S3-Uploads copied to clipboard

Integration with jpegoptim and optipng

Open eirisdg opened this issue 7 years ago • 15 comments

First of all, thanks for this fantastic plugin. Is not easy to find and is perfect for my project.

I think that image optimizing is one of the best practices in wordpress management to reduce image sizes. So, could be an option to be implemented tools like jpegoptim or optipng before the image starts to copy to S3?

Thanks.

eirisdg avatar Dec 22 '16 11:12 eirisdg

Hi @eirisdg, and thanks for using S3 Uploads. :)

Our plugins follow a general policy of aiming for completion, and hence generally not adding too many features. While it'd be great to have the ability to optimise images before they're uploaded, we don't believe it's something that should be in S3 Uploads itself. We want to keep this plugin focussed on the core ability of using S3.

This could be made as a separate plugin however, and we'd be happy to add any filters you need to implement this if it's not already possible.

rmccue avatar Dec 22 '16 13:12 rmccue

Would be great if this worked out of the box with EWWW Image Optimizer (https://en-au.wordpress.org/plugins/ewww-image-optimizer/). Feature request? 👍

jakejackson1 avatar Dec 29 '16 04:12 jakejackson1

@jakejackson1 If we can add support for EWWW easily and in a non-specific-to-EWWW way, we can certainly add that. We don't use it at HM (we use Tachyon instead), so it's unlikely that we'll put too much time into this, but if it's easy and simple, we can do so.

(If not, a bridging plugin that combines S3 Uploads and EWWW would be the suggested way forward.)

rmccue avatar Dec 29 '16 07:12 rmccue

And, Tachyon could be used in other websites? The readme file is not very clear and I don't know how to use it.

eirisdg avatar Dec 29 '16 10:12 eirisdg

FWIW I think the reason this doesn't work out the box with EWWW is that they both use a subclass of the Image_Editor class (at least in the case of Imagick), as such, S3 Uploads is probably setting the Image Editor to it's subclass, or visa versa. I don't know much way around that, using the OOP design. Yey OOP. Ideally, neither plugins would use this approach, it's a pretty big hack to swap out the image editor classes.

joehoyle avatar Dec 29 '16 15:12 joehoyle

@rmccue thanks for the info. I've removed EWWW for the time being as having the images on S3 is more important than automated image optimisation.

jakejackson1 avatar Jan 02 '17 21:01 jakejackson1

And, Tachyon could be used in other websites? The readme file is not very clear and I don't know how to use it.

You can absolutely run Tachyon yourself, however you're right that the docs are a bit lacking. We've been working on some newer ones.

rmccue avatar Jan 10 '17 02:01 rmccue

Will this plugin work well with WP Smush ?

elvismdev avatar Feb 02 '17 20:02 elvismdev

We haven't tested with WP Smush, but if they're using the standard hooks in WordPress to implement this, it should.

rmccue avatar Feb 03 '17 00:02 rmccue

@rmccue I just tested it with WP Smush, it sometimes work and sometimes doesn't work as intended.

For instance, when uploading a featured image to a post, it doesn't "Smush" the image on the fly (before upload) as expected, if I save the post, and come back to check the Featured Image, then it looks now like it did "Smush" it.

Attempting to "Smush" a single image from the Media library works the same, however the WP Smush plugin returns an error saying Error posting to API: 500 Internal Server Error, and it worries me that the plugin didn't actually finished the "Smush" task all successfully.

image

Also the same error happens when trying to use the Bulk Smush option from the plugin settings at /wp-admin/upload.php?page=wp-smush-bulk.

I'll be interested to try and patch WP Smush to work nicely with S3 Uploads.

Could you give me a brief idea on which principal standard hooks from WordPress should WP Smush be expected to use? That way I can look closely for those and the logic behind it to rubber-duck-debug what fails between this one and S3 Uploads, and hopefully fix it.

Thanks,

elvismdev avatar Feb 03 '17 03:02 elvismdev

The main thing that S3 Uploads does is hook into uploads_dir to change it from a regular path (/var/www/wp-content/uploads e.g.) to a stream wrapper path (s3://yourbucket). There are a number of secondary hooks, but the bulk of the functionality is there.

If WP Smush doesn't work, I suspect it's a problem with this.

rmccue avatar Feb 03 '17 04:02 rmccue

I would also love to see S3 Uploads plugin integrate with images optimization plugins. I tried all of the popular ones (Imagify, Kraken.io, EWWW, WP Smush It, Tinify) and none of them worked.

Thanks!

Tailzip avatar Feb 27 '17 20:02 Tailzip

I think we should install and test through all these plugins to understand and document why they don't work. It's possible they need changes upstream.

joehoyle avatar Feb 28 '17 01:02 joehoyle

Can confirm it doesn't work with Imagify plugin (Imagify v1.9.13 / S3-Uploads 2.2.2) - file gets uploaded correctly by S3-Uploads plugin, but Imagify returns error in admin area "Our server returned an error (0)." and can't process the image.

As an aside: https://deliciousbrains.com/wp-offload-media/ works with Imagify - not ideal due to their licensing model for larger sites.

Jonnyauk avatar Dec 21 '20 11:12 Jonnyauk

@rmccue, I do agree with you, "keep this plugin focussed on the core ability of using S3". @joehoyle, I am really impressed by your words

My favourite type of plugin is one that has focused single job, requires little configuration and “just works”.

in humanmade.com. Couldn't agree more! Big fan!

My case:

  1. Click to upload a 2MB JPG image in WordPress media library
  2. S3 UPLOADS upload it to S3
  3. Go to S3 console and check, only this image file exists. No other optimised ones.

If I am not the only one, this slows down image loading on web page. Even when viewing image thumbnails in wp-admin media library.

  1. Deactivate S3 UPLOADS
  2. Click to upload a 2MB JPG image in WordPress media library
  3. Go to .../wp-content/uploads/... and check, many optimised images exsits with the original one:
...-1024x465.jpg
...-150x150.jpg
...-1536x698.jpg
...-1568x712.jpg
...-2048x930.jpg
...-300x136.jpg
...-768x349.jpg
....jpg

I guess, if not wrong, the original process works like this: User upload image --> WordPress optimise it into different sizes --> Wordpress save them to local folder

S3 UPLOADS is expected to work like this: User upload image --> WordPress optimise it into different sizes --> S3 UPLOADS upload them onto S3 bucket

@Jonnyauk, as far as I know, wp-offload-media you mentioned works like this: User upload image --> WordPress optimise it into different sizes --> Wordpress save them to local folder --> wp-offload-media copy them & upload them onto S3 bucket --> wp-offload-media rewrites image links or urls After this process, you can choose to delete all the images in local.

When using S3 UPLOADS, I am sure the settings are correct by wp s3-uploads verify, I am sure I can upload images to S3 successfully. I found another side effect:

I installed Ajax Load More(ALM), when saving ALM's setting, it warns something like:

Error Writing File
Something went wrong and the data could not be saved.

According to this thread, ALM expect to save a file in .../wp-content/uploads/. Something went wrong when S3 UPLOADS tries to upload the file onto S3.

I installed Cerber Security, when saving its setting, it warns like:

ERROR: Unable to create the file s3://my-bucket-name/uploads/.htaccess

The problem is obvious: S3 UPLOADS can handle image uploading correctly, but not compatible with other plugins' settings files.

But, when using wp-offload-media, no problem like this. All the plugins can visit local folders like .../wp-content/uploads/ as usual.

After all, I think, it would be pretty hard to ask S3 UPLOADS to deal with other plugins, I should find workarounds by asking their supporting team.

But I would be grateful if S3 UPLOADS could upload optimised images to help web page load faster.

Thank you, HumanMade team, for following right concepts and developing plugins for human!

killDevils avatar Mar 06 '21 03:03 killDevils