=== LAFU Photon Media Optimizer ===
Contributors: elsama101
Tags: image optimization, compress images, webp, product images, image compression
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.6.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Compress images in the background, keep every original, and give product photos a clean, uniform canvas so nothing gets cut off.

== Description ==

Big images slow your site down, and shop themes often cut product photos to fit a square. LAFU Photon Media Optimizer fixes both quietly in the background, and every original stays safe so you can always go back.

**Works without an account.** Images compress on your own server out of the box. Connect a free Photon account when you want stronger compression, and your server does less of the work.

= Why people choose LAFU Photon =

* **Runs in the background.** Upload as usual. Images are compressed in a queue, so nobody waits and your admin stays fast.
* **Every original is kept.** Restore one image or all of them, whenever you like.
* **Product photos stop getting cut off.** Uniform canvas centers each image on a same-shape background, so a wide keyboard shows from end to end.
* **Handles a whole library.** One click queues every image, and a run picks up where it left off after a timeout or a restart.

= Compression =

* JPEG, PNG and WebP. AVIF copies are optional.
* **WebP for your visitors.** Every image and all its thumbnails get a WebP version, made on your server and shown on your pages, so shop and archive pages get lighter too. It uses no Photon volume.
* Choose the quality, and a maximum image size for very large uploads.
* Images that would not get smaller are left alone.
* Small files are skipped, because compressing them gains nothing.

= Uniform canvas =

Off until you turn it on.

* Centers images on a canvas of the same shape, so WooCommerce and theme crops stop cutting off product edges.
* Choose the canvas size and margin, with a white or transparent background.
* Use it on product images only, or on all images.
* New images get it automatically, and one button updates the images you already have.
* Small images are not stretched, and images that already have the right shape are left alone.
* Take it off again at any time. The originals stay in the backups.

= Media Library =

* Status and savings for each image, with buttons to optimize or restore it.
* One click queues the whole library, and the settings page shows progress and an estimated time.
* WP-CLI commands: `wp lafu optimize`, `wp lafu restore` and `wp lafu canvas`.
* Works with LAFU Offload Media when images live in object storage.

= Photon plans =

Local compression on your own server is free and has no limit. The Photon cloud service is optional and has a free plan with 1 GB a month. [Paid plans](https://www.lanetti.fi/products/photon) add more monthly volume. A plan changes how much Photon compresses for you each month; every feature of this plugin is included either way.

== External services ==

When a Photon API key is configured, this plugin connects to the Photon compression API at https://photon.lanetti.fi (allowlisted; photon.lafu.fi is also accepted). Image bytes, the API key, and this site hostname are sent over HTTPS. Without an API key, no cloud calls are made.

Account service: when an administrator presses Connect under Media → Photon Optimizer, the plugin sends the email address they enter, this site address and the WordPress admin language to https://oma.lanetti.fi/api/photon/v1 to create a free key after the email link is confirmed. With a key saved, the plugin reads the plan and this month's usage from the same service (twice a day and when the settings page is open), and asks it for an upgrade link when an administrator presses Upgrade.

Service terms: https://lanetti.fi/legal/photon
Privacy policy: https://lanetti.fi/legal/privacy

== Installation ==

1. Install and activate LAFU Photon Media Optimizer. New uploads are now compressed on your server.
2. Optional: open Media > Photon Optimizer, enter your email and press Connect, then click the link in the email. You can also paste an API key.
3. Open Media > Optimize to compress the images you already have.
4. Optional: turn on Uniform canvas in the settings, then use Tools to update existing images.

== Frequently Asked Questions ==

= Do I need an account? =

No. Without an account the plugin compresses images on your own server and sends nothing anywhere. An account is only needed for the Photon cloud service.

= What gets sent to Photon? =

Only when you have connected an account: the image being compressed, your API key and your site address. See External services above.

= Can I get my original images back? =

Yes, as long as source backups are on, which is the default. Restore one image from the Media Library, or all of them under Tools.

= What happens when my monthly Photon volume runs out? =

Images keep being compressed on your server until the next month, with smaller savings. Your site and existing images are not affected.

= Does serving WebP change my image URLs? =

Image tags on your pages point to the WebP versions. The original files stay where they are, and direct links and product feeds keep using them. If you use a page cache, clear it after making WebP versions for existing images.

= Will Uniform canvas change my image URLs? =

The full-size image keeps its URL. Thumbnails can get new names because their shape changes, and WordPress picks up the new names by itself. If you use a page cache or a CDN, clear it after updating existing images.

= Why are some product images unchanged by Uniform canvas? =

They already have the shape of your canvas, so they would not be cut off.

= Does it need WooCommerce? =

No. Compression works on any WordPress site. With WooCommerce, Uniform canvas can target product images only.

= Does it slow down my site? =

Work happens in the background queue, not on normal page views. For large libraries, a real system cron keeps the queue moving steadily.

== Screenshots ==

1. Settings: connection, output formats and Uniform canvas.
2. A shop page with Uniform canvas: whole products in equal squares.
3. Optimize the whole Media Library in one click.
4. Tools: apply the canvas to existing images, restore originals and run the queue.

== Changelog ==

= 1.6.0 =
* New: WebP for your visitors. Every image and all its thumbnails get a WebP version, made on your server, and your pages show them. Uses no Photon volume. WP-CLI: `wp lafu webp`.

= 1.5.0 =
* Notices now show only on the plugin's own pages.
* Parallel queue speed no longer depends on the plan.
* Removed the old unprefixed hooks before_optimize, after_optimize and optimize_failed. Use the lafu_media_optimizer_ versions.

= 1.4.1 =
* Offload refresh retries a refused upload and reports a failed thumbnail upload, which used to be ignored.

= 1.4.0 =
* New: Uniform canvas centers images on a canvas of the same shape, so WooCommerce and theme crops stop cutting off product edges. Choose the size, margin, white or transparent background, and product images or all images.
* Tools can apply the canvas to existing images or take it off again. Originals stay in the backups. WP-CLI: `wp lafu canvas`.
* Fixed: optimizing an image that was already WebP or AVIF could delete the image file when next-gen copies were on.

= 1.3.0 =
* Connect from the plugin with your email address, without copying a key. See your plan and usage, and upgrade in one click. The monthly cap follows the plan.

= 1.2.7 =
* Honest statuses for missing and broken files, and the real upload limit.

= 1.2.5 =
* Parallel queue workers.

= 1.2.4 =
* Fixed a stuck bulk queue, faster runs, Finnish and Swedish translations.

= 1.2.0 =
* Canonical Photon WordPress client: Media menu, local-only mode without cloud calls, dismissible banner, hosted OMA key support, engine host allowlist and secure remote args.
* Settings and Tools under Media → Photon Optimizer. Cleaner connection copy.

= 1.1.2 =
* Display name: LAFU Photon Media Optimizer (same slug, options, and meta).

= 1.1.1 =
* Plugin Check clean: wp_is_writable, readme Tested up to 7.1, five tags max.

= 1.1.0 =
* Display name: Photon Media Optimizer (same slug, options, and meta).

= 1.0.1 =
* Prior LAFU Media Optimizer release.
