-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
In our implementation when writing a provider for AMF, on local environments where production images are missing, I'm seeing a number of media.php warnings strpos(): Empty needle
.
When debugging it appears that for these images, both $dirname
and $file
are empty.
I added this workaround, to repopulate the file value with the one from $image_meta
:
add_filter( 'wp_calculate_image_srcset_meta', __NAMESPACE__ . '\\insert_missing_meta_sizes_values', 10, 1 );
[..]
/**
* Some images that are not locally available, have empty values causing warnings.
*
* @param array $image_meta
*
* @return array Updated image meta sizes array with empty file values replaced.
*/
function insert_missing_meta_sizes_values( array $image_meta ) : array {
foreach ( $image_meta['sizes'] as $key => $size ) {
if ( empty( $size['file'] ) ) {
$image_meta['sizes'][ $key ]['file'] = $image_meta['file'];
}
}
return $image_meta;
}
When I have AMF/Provider disabled, I don't see these warnings. It could be an assumption on AMF's part or something else in our codebase, but wanted to report this in case this helps solving the issue should it be AMF related.
Metadata
Metadata
Assignees
Labels
No labels