Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ composer.lock
.phpunit.cache/
.phpcs-cache
dist/
.phpunit.result.cache
41 changes: 9 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Client-Side Media Experiments

Enables client-side media processing on Firefox and Safari via COEP/COOP cross-origin isolation headers, and adds HEIC/HEIF upload support with automatic client-side conversion to JPEG.
Enables client-side media processing on Firefox and Safari via COEP/COOP cross-origin isolation headers.

## Features

### Cross-Origin Isolation (COEP/COOP)

WordPress 7.0 and Gutenberg include client-side media processing powered by WebAssembly (wasm-vips). This requires cross-origin isolation, which is achieved via Document-Isolation-Policy (DIP) on Chrome 137+.
WordPress 7.1 and Gutenberg include client-side media processing powered by WebAssembly (wasm-vips). This requires cross-origin isolation, which is achieved via Document-Isolation-Policy (DIP) on Chrome 137+.

However, Firefox and Safari do not yet support DIP, so client-side media processing is disabled on those browsers.

Expand All @@ -17,50 +17,29 @@ This plugin restores support by sending the older COEP/COOP headers on browsers
- Adds `credentialless` attribute to iframes so they continue working under COEP.
- Filters embed previews for providers that do not support credentialless iframes (Facebook, SmugMug).

### HEIC/HEIF Upload Support
### HEIC uploads

HEIC support was removed from WordPress core's wasm-vips build due to LGPL/GPL license incompatibility. This plugin re-enables HEIC upload support by converting images client-side:

- **Enabled by default** — can be toggled under **Settings → Media**.
- HEIC/HEIF images are automatically converted to JPEG in the browser before upload.
- Uses the [heic2any](https://github.com/alexcorvi/heic2any) library, loaded dynamically from an external CDN only when a HEIC file is detected.
- heic2any uses [libheif](https://github.com/strukturag/libheif) (LGPL-3.0) for decoding. Since it is loaded at runtime from a CDN rather than bundled with the plugin, it is treated as a separate work and does not affect the plugin's GPL-2.0-or-later license.
WordPress 7.1 handles HEIC/HEIF uploads in core: MIME types, file type detection, HEIC-to-JPEG output mapping, and client-side conversion via the vips WASM pipeline or a canvas-based fallback for browsers with native HEVC decoding (such as Safari). This plugin no longer ships any HEIC handling of its own.

## Requirements

- WordPress 6.8+ with the Gutenberg plugin, or WordPress 7.0+.
- The client-side media processing feature must be enabled.
- WordPress 6.8+ with the Gutenberg plugin, or WordPress 7.1+.
- The client-side media processing feature must be enabled (it is on by default in secure contexts).

## Installation

1. Upload the `client-side-media-experiments` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. The COEP/COOP headers activate automatically on browsers that need them. HEIC support is enabled by default.
3. The COEP/COOP headers activate automatically on browsers that need them.

## Configuration

### Disable COEP/COOP headers

```php
add_filter( 'csme_use_coep_coop', '__return_false' );
```

### Disable HEIC support

Navigate to **Settings → Media** and uncheck **HEIC Support**, or programmatically:
Navigate to **Settings → Media** and uncheck **Enable**, or programmatically:

```php
update_option( 'csme_heic_enabled', 0 );
```

### Self-host the HEIC conversion library

Use the `csme_heic_library_url` filter to point to your own hosted copy of heic2any:

```php
add_filter( 'csme_heic_library_url', function () {
return 'https://example.com/heic2any.min.js';
} );
add_filter( 'csme_use_coep_coop', '__return_false' );
```

## Development
Expand All @@ -78,5 +57,3 @@ This produces `dist/client-side-media-experiments.zip` containing only the runti
## License

This plugin is licensed under [GPL-2.0-or-later](https://www.gnu.org/licenses/gpl-2.0.html).

The HEIC conversion library ([heic2any](https://github.com/alexcorvi/heic2any) / [libheif](https://github.com/strukturag/libheif)) is LGPL-3.0 licensed and loaded at runtime from an external CDN as a separate work.
3 changes: 1 addition & 2 deletions client-side-media-experiments.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Client-Side Media Experiments
* Plugin URI: https://github.com/adamsilverstein/client-side-media-experiments
* Description: Enables client-side media processing on Firefox and Safari via COEP/COOP cross-origin isolation headers, and adds HEIC/HEIF upload support with client-side conversion.
* Description: Enables client-side media processing on Firefox and Safari via COEP/COOP cross-origin isolation headers.
* Version: 0.2.0
* Requires at least: 6.8
* Requires PHP: 7.4
Expand Down Expand Up @@ -46,6 +46,5 @@ function csme_init() {

require_once CSME_PLUGIN_DIR . 'includes/settings.php';
require_once CSME_PLUGIN_DIR . 'includes/cross-origin-isolation.php';
require_once CSME_PLUGIN_DIR . 'includes/heic-support.php';
}
add_action( 'plugins_loaded', 'csme_init' );
194 changes: 0 additions & 194 deletions includes/heic-support.php

This file was deleted.

35 changes: 0 additions & 35 deletions includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ function csme_register_settings() {
'media',
'csme_settings_section'
);

register_setting(
'media',
'csme_heic_enabled',
array(
'type' => 'integer',
'default' => 1,
'sanitize_callback' => 'csme_sanitize_enabled',
)
);

add_settings_field(
'csme_heic_enabled_field',
__( 'HEIC Support', 'client-side-media-experiments' ),
'csme_heic_enabled_field_callback',
'media',
'csme_settings_section'
);
}
add_action( 'admin_init', 'csme_register_settings' );

Expand Down Expand Up @@ -96,23 +78,6 @@ function csme_enabled_field_callback() {
<?php
}

/**
* Outputs the checkbox field for the HEIC enabled setting.
*/
function csme_heic_enabled_field_callback() {
$enabled = get_option( 'csme_heic_enabled', 1 );
?>
<input type="hidden" name="csme_heic_enabled" value="0" />
<label for="csme_heic_enabled">
<input type="checkbox" id="csme_heic_enabled" name="csme_heic_enabled" value="1" <?php checked( $enabled, 1 ); ?> />
<?php esc_html_e( 'Enable HEIC/HEIF image upload support (converts to JPEG on the client side).', 'client-side-media-experiments' ); ?>
</label>
<p class="description">
<?php esc_html_e( 'When enabled, HEIC images are converted to JPEG in the browser using the heic2any library (which uses libheif, LGPL-3.0 licensed), loaded from an external CDN at runtime.', 'client-side-media-experiments' ); ?>
</p>
<?php
}

/**
* Disables COEP/COOP when the setting is off.
*
Expand Down
Loading
Loading