Skip to content

Commit

Permalink
Fix warning wp_list_pluck on missing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
HTMLBurger-NG committed Feb 21, 2023
1 parent 1df4bc7 commit 43016a3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ public static function get_attachment_id( $url ) {
foreach ( $query->posts as $post_id ) {
$meta = wp_get_attachment_metadata( $post_id );
$original_file = wp_basename( $meta['file'] );
$cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
$sizes = isset( $meta['sizes'] ) && ! empty( $meta['sizes'] ) ? $meta['sizes'] : array();
$cropped_image_files = wp_list_pluck( $sizes, 'file' );

if ( $original_file === $filename || in_array( $filename, $cropped_image_files ) ) {
$attachment_id = intval( $post_id );
Expand Down

0 comments on commit 43016a3

Please sign in to comment.