value(); if ( ! empty( $value ) ) { if ( is_array( $value ) && isset( $value['id'] ) ) { $attachment_id = $value['id']; } elseif ( is_numeric( $value ) ) { $attachment_id = absint( $value ); } elseif ( is_string( $value ) && ! is_numeric( $value ) ) { $attachment_id = attachment_url_to_postid( $value ); } if ( ! empty( $attachment_id ) ) { $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id ); } } } }