=== Lattice Media Optimizer ===
Contributors: darkvision
Tags: image optimization, webp, avif, media, performance
Requires at least: 5.8
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically optimizes images on upload via the Lattice Media Engine API.

== Description ==

Lattice Media Optimizer intercepts image uploads and sends them to the [Lattice Media Engine](https://lattice.darkvision.dev) for optimization. The optimized image replaces the original **before** WordPress generates thumbnails, so every size benefits from the optimization.

**Features:**

* Automatic optimization on upload — no manual steps required
* Convert to WebP, AVIF, JPEG, or PNG, or keep the original format
* Adjustable quality (1–100)
* Optional max width/height resize with aspect ratio preserved
* Strip EXIF and other metadata
* Works with WooCommerce, REST API, and WP-CLI uploads
* Fail-safe design — if the API is unreachable, uploads proceed normally
* API key encrypted at rest using AES-256-CBC

**Requirements:**

* A Lattice Media Engine API key ([sign up](https://lattice.darkvision.dev))
* PHP 7.4+ with the OpenSSL extension (recommended for encryption)

== Installation ==

1. Upload the `lattice-media-optimizer` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** menu.
3. Go to **Settings > Lattice Optimizer**.
4. Enter your Lattice API key and click **Save Changes**.
5. Click **Test Connection** to verify.
6. Check the **Enable** box and save.

== Frequently Asked Questions ==

= What happens if the Lattice API is down? =

The plugin is fail-safe. If the API is unreachable, returns an error, or the download fails, the original image is kept and the upload proceeds normally. An error is logged on the settings page.

= Does this work with other image optimization plugins? =

Lattice runs at upload time (before thumbnails). Other plugins that optimize thumbnails after generation will still work but may do redundant work. You can disable thumbnail optimization in those plugins if desired.

= Which image formats are supported? =

JPEG, PNG, and WebP uploads are sent to the API. GIF, SVG, and other formats pass through untouched.

= What does "Auto Cleanup" do? =

When enabled (default), the plugin deletes the optimized file from Lattice storage after downloading it. This frees up your Lattice storage quota. The file is already saved in your WordPress uploads directory.

= Is my API key stored securely? =

Yes. The API key is encrypted with AES-256-CBC using your site's `AUTH_KEY` before being saved to the database. It is only decrypted in memory when making API calls.

== Changelog ==

= 1.0.0 =
* Initial release.
