Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add Tiny_Plugin::compress() for general usage by devs #21

Open
mklepaczewski opened this issue Feb 12, 2021 · 2 comments

Comments

@mklepaczewski
Copy link

The plugin covers basic functionality. However, as a developer, I sometimes need to do custom tasks that aren't covered by the plugin (for example, I wrote WP CLI wrapper around the plugin). Compression is currently triggered during various events, but it seems there's no easy way to execute it manually from standalone PHP code. I propose to add Tiny_Plugin::compress(). Ideally, for consistency reasons, all other compression methods should rely on and call it:

  • Tiny_Plugin::compress_on_upload(),
  • Tiny_Plugin::compress_image_from_library(),
  • Tiny_Plugin::compress_image_for_bulk()

I can submit PR if this feature request is accepted.

@mklepaczewski
Copy link
Author

Note that I'm aware of Tiny_Image::compress(), but it requires Tiny_Settings which isn't easily available from Tiny_Plugin. For now Tiny_Plugin::settings is just vanilla new Tiny_settings(), but who knows if it stays that in the future ;-)

@mattijsvandruenen
Copy link
Contributor

Hi Matt,

Thanks for writing us here as well!

I don't think the Tiny_Settings constructor will change any time soon. It's been this way for years already, and I don't see any future need to pass along something dynamic to that constructor. You should therefore be fine instantiating a Tiny_Image with a new Tiny_Settings() and then call the compress function to have all its configured image sizes compressed.

On the other hand, I do see the added value of having an easy to use function to compress an image from code outside of the plugin. For example, a function that only needs the ID of the image you want to compress. That also helps in case we do decide to change the internals of Tiny_Image, Tiny_Settings and the compress method. Feel free to submit a PR for that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants