=== Chompix ===
Contributors: gameygv
Tags: avif, webp, image optimization, performance, images
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.1.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Converts your images to AVIF and WebP in the cloud. Needs nothing from your hosting: no GD, no Imagick, no server configuration.

== Description ==

Chompix converts the images you upload to WordPress into AVIF and WebP on our servers, then serves them to the browsers that support them. Your hosting does not need GD, Imagick, `exec()` or any server module: the plugin only needs to make outgoing HTTPS requests.

**How it works**

1. You upload a photo to the media library, as always. WordPress creates its usual sizes.
2. The plugin sends the original once to the Chompix service, together with the list of sizes your site uses.
3. The service creates the AVIF and WebP version of every size and the plugin saves them next to your files (`photo-300x200.jpg.avif`, `photo-300x200.jpg.webp`).
4. On the front end, images are wrapped in a `<picture>` element, so each browser picks the best format it supports. It works on Apache, Nginx and behind any CDN, without touching the server configuration.

**Features**

* AVIF and WebP for every size WordPress creates, from a single upload.
* A version is discarded when it would be larger than the file it replaces.
* Delivery through `<picture>`: no `.htaccess` or Nginx rules needed.
* Optional watermark (your logo as a PNG, or a text) applied on our servers to the AVIF and WebP versions, with a live preview. Your original files are never modified.
* Site check: before doing anything, the plugin looks for other image converters, active or past, and never overwrites files it did not create.
* If the service is unavailable, uploads work as usual and your site keeps serving the original images.
* WP-CLI: `wp chompix convert <id>...`, `wp chompix convert --failed` and `wp chompix doctor`.
* Uninstalling removes the plugin's settings, its metadata and every AVIF and WebP file it created. Nothing else.

**One credit per photo**

Each photo you upload uses one credit, no matter how many sizes WordPress creates from it. The free plan includes 60 photos a month, AVIF included. Paid plans raise that limit; the plugin works the same on every plan.

== External services ==

This plugin relies on the Chompix conversion service, operated by Chompix at `https://api.chompix.top`. It is needed to convert images, which is the plugin's main purpose.

**Nothing is sent until you save an API key** in Settings → Chompix, or click "Get a free API key". Without a key, the plugin makes no outgoing requests at all.

* **When you click "Get a free API key"** (only shown while there is no key): the email address in the form and your admin language, so the service can create a free account and email you the key. Nothing else is sent.

Once a key is saved, the plugin sends:

* **When you upload an image** (JPEG, PNG or WebP) or run `wp chompix convert`: the original image file, the names and dimensions of your site's image sizes and the file size of each one, your API key, and, if the watermark is on, its settings and your logo file.
* **When you click "Show preview"** in the watermark settings: the watermark settings and your logo file. A sample photo stored on the service is used, so none of your images are sent.
* **When you open the settings page or click "Test connection"**: your API key, to show your plan and usage.
* **With every request**: your site's address, in the `User-Agent` header.

Where and for how long:

* The service runs on servers located in the United States. Traffic reaches it through the Cloudflare network ([Cloudflare Terms](https://www.cloudflare.com/terms/), [Cloudflare Privacy Policy](https://www.cloudflare.com/privacypolicy/)).
* The original image is deleted as soon as the conversion finishes. The converted files are deleted as soon as your site downloads them, and after 24 hours at most if they are never downloaded.
* The watermark logo is used only for that request and is deleted with the original image.
* The service keeps your account email, a hash of your API key and how many photos you converted in each period, to apply your plan. Request logs record only the method, path, status code and timing; they do not include images, your site's address or your IP address.

Terms of service: https://chompix.top/terms
Privacy policy: https://chompix.top/privacy

== Installation ==

1. Install the plugin from Plugins → Add New, or upload the `chompix` folder to `/wp-content/plugins/`.
2. Activate it.
3. Go to Settings → Chompix. If you do not have an API key yet, click "Get a free API key": it arrives by email in a minute. Paste it and save.
4. Click "Test connection". From then on, every image you upload is converted.

To convert the images you uploaded before installing the plugin, click "Convert the whole library" in Settings → Chompix. The service converts them in small batches in the background, so you can close the page. With WP-CLI: `wp chompix bulk start`, or `wp chompix convert --all` to do it in the terminal.

== Frequently Asked Questions ==

= Does my hosting need GD or Imagick? =

No. The conversion happens on our servers. Your hosting only needs to make outgoing HTTPS requests, which WordPress already does for updates.

= Are my original images modified? =

No. The AVIF and WebP files are saved next to the originals with an extra extension. The watermark, if you turn it on, is applied only to the AVIF and WebP versions.

= What happens if the service is down or I run out of credits? =

Uploads keep working and your site serves the original images. Images that could not be converted are marked as failed; convert them again with `wp chompix convert --failed`.

= Does it work with Nginx and CDNs? =

Yes. Delivery uses the `<picture>` element in your HTML, so it does not depend on server rules and works behind any CDN.

= I used another image optimization plugin before. Is that a problem? =

The plugin checks your site for other converters, active or past, and shows what it found in Settings → Chompix. It never deletes or overwrites files created by other plugins.

= What does uninstalling remove? =

The plugin's settings, its metadata on each image and every AVIF and WebP file it created. Your original images and anything left by other plugins stay untouched.

== Screenshots ==

1. No API key yet? Get a free one by email from the settings page.
2. Delivery: `<picture>` everywhere, plus same-URL delivery when the server allows it.
3. Watermark with your logo or a text, with a live preview.
4. Site check: other image plugins, active or past, so nothing conflicts.

== Changelog ==

= 0.1.4 =
* Translations are delivered by translate.wordpress.org; the plugin no longer bundles or loads its own translation files.

= 0.1.3 =
* Fix: a failed re-conversion no longer forgets the AVIF/WebP files written before, so they are still removed when the image is deleted or the plugin is uninstalled.
* Fix: retrying failed images removes their old files first.
* Fix: on very large pages the page filter leaves the HTML untouched if PCRE fails, instead of editing inside scripts or dropping parts of the page.
* Fix: saving the settings refreshes the cached plan and library status.

= 0.1.2 =
* Fix: images whose `<picture>` was removed by another filter (Elementor's image widget) are wrapped again, so they are served as AVIF or WebP.

= 0.1.1 =
* Library panel in Settings: convert the whole library in the background, pause, resume and retry failed images.

= 0.1.0 =
* First version: conversion on upload, delivery through `<picture>` and same-URL server rules, bulk conversion of the existing library driven by the service, free API key by email, watermark with preview, site check and WP-CLI commands.
