I am receiving the following error in PHP
8 Undefined offset: 1/Applications/MAMP/htdocs/wordpress/wp-content/plugins/wp-plugin/core.php 2178
Here is the PHP code that causes it:
if (isset ( $attachements_to_attach ) && count ( $attachements_to_attach ) > 0) {
require_once (ABSPATH . 'wp-admin/includes/image.php');
foreach ( $attachements_to_attach as $attachements_to_attach_single ) {
$file = $attachements_to_attach_single [0];
$attachment = $attachements_to_attach_single [1];
$post_id = $id;
if (! function_exists ( 'wp_plugin_filter_image_sizes' )) {
function wp_plugin_filter_image_sizes($sizes) {
$sizes = array ();
return $sizes;
}
}
if (! in_array ( 'OPT_FEED_MEDIA_ALL', $camp_opt )) {
add_filter ( 'intermediate_image_sizes_advanced', 'wp_plugin_filter_image_sizes' );
}
$attach_id = wp_insert_attachment ( $attachment, $file, $post_id );
$attach_data = wp_generate_attachment_metadata ( $attach_id, $file );
wp_update_attachment_metadata ( $attach_id, $attach_data );
} <!-- error in this line
// remove sizes filter
remove_filter ( 'intermediate_image_sizes_advanced', 'wp_plugin_filter_image_sizes' );
}