Check that is really an attachment and not the global $post object.

Prevents Notices of Trying to access array offset on value of type bool because $src variables will be false.
This commit is contained in:
David Stone 2019-11-06 00:25:48 -07:00
parent a6819ad495
commit 0d5c697123
1 changed files with 1 additions and 1 deletions

View File

@ -715,7 +715,7 @@ function wc_get_product_attachment_props( $attachment_id = null, $product = fals
);
$attachment = get_post( $attachment_id );
if ( $attachment ) {
if ( $attachment && 'attachment' === $attachment->post_type ) {
$props['title'] = wp_strip_all_tags( $attachment->post_title );
$props['caption'] = wp_strip_all_tags( $attachment->post_excerpt );
$props['url'] = wp_get_attachment_url( $attachment_id );