Skip to content
Open
Changes from 5 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
10 changes: 9 additions & 1 deletion classes/Picture/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,15 @@ protected function build_picture_tag( $image ) {
unset( $attributes['data-object-position'] );
}

$output = '<picture' . $this->build_attributes( $attributes ) . ">\n";
$picture_attributes = array_filter(
$attributes,
function ( $attribute ) {
return strpos( $attribute, 'data-wp' ) === false;

Copilot AI Jan 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current check using strpos($attribute, 'data-wp') === false will filter out any attribute containing 'data-wp' anywhere in the key name, not just those starting with 'data-wp'. For more precise filtering of WordPress-specific attributes, consider using strpos($attribute, 'data-wp-') !== 0 or strncmp($attribute, 'data-wp-', 8) !== 0 to ensure only attributes that start with 'data-wp-' are filtered out. This prevents accidentally filtering attributes that may contain 'data-wp' in other positions.

Suggested change
return strpos( $attribute, 'data-wp' ) === false;
return strncmp( $attribute, 'data-wp-', 8 ) !== 0;

Copilot uses AI. Check for mistakes.
},
ARRAY_FILTER_USE_KEY
);
Comment on lines +221 to +227

Copilot AI Jan 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an inline comment above the array_filter call to explain why data-wp attributes are being filtered out from the picture tag. This would help future maintainers understand the purpose of this filtering, especially in relation to the lightbox fix mentioned in issue #758.

Copilot uses AI. Check for mistakes.

$output = '<picture' . $this->build_attributes( $picture_attributes ) . ">\n";
/**
* Allow to add more <source> tags to the <picture> tag.
*
Expand Down
Loading