Automattic / Automattic/jetpack

[Bug] jetpack-carousel.php infuses massive redundant EXIF metadata even when disabled (Regression/Unresolved from #32819 and #32862)

Open
#49,427 1 comment 0 reactions 1 assignee Claimed by @manzoorwanijk View on GitHub
Bug Needs triage
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

### Impacted plugin

Jetpack

### Quick summary

### Associated Closed Issues
This is a direct follow-up and reopen request for unresolved performance issues originally reported in September 2023:
- https://github.com/Automattic/jetpack/issues/32819
- https://github.com/Automattic/jetpack/issues/32862

### Description
It has been nearly three years since this severe performance and architectural bottleneck was exposed, and unfortunately, the core code structure remains completely unoptimized upstream.

Jetpack Support recently officially confirmed that the toggle option *"Show photo EXIF metadata in carousel"* **does NOT** stop the server from processing and injecting thousands of lines of redundant HTML/layout data into the source code. Instead, the plugin injects the metadata regardless of the toggle and merely hides it on the front-end via CSS/JavaScript.

For websites hosting massive multimedia ecosystems and extensive image catalogs, this creates an enormous, unacceptable amount of unnecessary page weight and bloated DOM size.

### Current Workaround (Manual Patching)
For years, advanced users and IT specialists have been forced to manually patch `jetpack-carousel.php` after every single plugin update to maintain acceptable site performance. Specifically, we have to manually comment out legacy structures such as:
1. The `meta_data` arrays around line 474:
```php
/*'meta_data' => array( 'camera', 'aperture', 'shutter_speed', 'focal_length', 'copyright' ),*/

### Steps to reproduce

Install and activate the latest version of the Jetpack plugin.

Go to Jetpack settings and enable the Carousel feature.

In the Carousel settings, ensure that the option "Show photo EXIF metadata in carousel" is turned OFF (disabled).

Upload any high-quality photograph containing rich EXIF metadata (camera, aperture, shutter speed, etc.) to a WordPress post or page inside a Gallery block.

Publish the post and view the front-end page source code (HTML).

Search for data-image-meta or inspect the gallery HTML markup.

Actual result: Massive blocks of raw EXIF metadata strings are still fully processed by the server and hard-coded into the HTML payload, even though the front-end toggle is disabled.
Expected result: The server should completely bypass extracting and printing the metadata to the HTML DOM when the dashboard setting is deactivated.

### Site owner impact

More than 60% of the total website/platform users

### Severity

Major

### What other impact(s) does this issue have?

No revenue impact

### If a workaround is available, please outline it here.

Currently, the only way to mitigate this severe DOM bloat is to manually patch `jetpack-carousel.php` after every single plugin update using the following dirty workaround:

1. Locate the file: `wp-content/plugins/jetpack/modules/carousel/jetpack-carousel.php`
2. Go to around line 474 and manually comment out the meta_data array fields:
/*'meta_data' => array( 'camera', 'aperture', 'shutter_speed', 'focal_length', 'copyright' ),*/
3. Go to around line 950 and comment out the image attribute layout string:
#$attr['data-image-meta'] = esc_attr( $img_meta );

Alternatively, a custom server-side filter must be written to strip the attributes before DOM rendering, which adds unnecessary execution overhead. An upstream fix is urgently required.

### Alternative Programmatic Workaround (functions.php filter)

For those who want to avoid modifying core plugin files after every update, you can use this custom server-side filter to strip the redundant metadata payload from the carousel output dynamically.

*Note: While this slims down the final HTML DOM weight, it is still a workaround and does not fix the root architectural issue—the server is still wastefully processing and compiling this data before the filter strips it.*

```php
/**
* Jetpack Carousel Performance Fix
* Strips bloated image metadata attributes when EXIF display is disabled in settings.
*/
add_filter( 'jetpack_carousel_get_images', function( $images ) {
// Check if Jetpack Carousel exists and if EXIF display is globally disabled
if ( class_exists( 'Jetpack_Carousel' ) ) {
$carousel_option = get_option( 'carousel_display_exif', '0' );

// If "Show photo EXIF metadata" is turned off, completely strip the data payload
if ( '0' === $carousel_option && is_array( $images ) ) {
foreach ( $images as &$image ) {
if ( isset( $image['data-image-meta'] ) ) {
$image['data-image-meta'] = ''; // Strip server-compiled layout bloat
}
}
}
}
return $images;
}, 20 );

### Platform (Simple and/or Atomic)

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.