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:
parent
a6819ad495
commit
0d5c697123
|
@ -715,7 +715,7 @@ function wc_get_product_attachment_props( $attachment_id = null, $product = fals
|
||||||
);
|
);
|
||||||
$attachment = get_post( $attachment_id );
|
$attachment = get_post( $attachment_id );
|
||||||
|
|
||||||
if ( $attachment ) {
|
if ( $attachment && 'attachment' === $attachment->post_type ) {
|
||||||
$props['title'] = wp_strip_all_tags( $attachment->post_title );
|
$props['title'] = wp_strip_all_tags( $attachment->post_title );
|
||||||
$props['caption'] = wp_strip_all_tags( $attachment->post_excerpt );
|
$props['caption'] = wp_strip_all_tags( $attachment->post_excerpt );
|
||||||
$props['url'] = wp_get_attachment_url( $attachment_id );
|
$props['url'] = wp_get_attachment_url( $attachment_id );
|
||||||
|
|
Loading…
Reference in New Issue