From e746f62945b8050bfa97661b7b10625ca2d2940c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Ram=C3=B3n?= Date: Tue, 17 Apr 2018 11:41:37 +0200 Subject: [PATCH] fix error in mpd_get_image_alt_tags The post_media_attachment object is an array with two values object and attached_file_path --- inc/mpd-functions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/inc/mpd-functions.php b/inc/mpd-functions.php index f01cce3..bf03bef 100644 --- a/inc/mpd-functions.php +++ b/inc/mpd-functions.php @@ -638,7 +638,11 @@ function mpd_get_image_alt_tags($post_media_attachments){ foreach ($post_media_attachments as $post_media_attachment) { - $alt_tag = get_post_meta($post_media_attachment->ID, '_wp_attachment_image_alt', true); + if(array_key_exists("object",$post_media_attachment)) + $post_id = $post_media_attachment["object"]->ID; + else + $post_id = $post_media_attachment->ID; + $alt_tag = get_post_meta($post_id, '_wp_attachment_image_alt', true); $alt_tags_to_be_copied[$attachement_count] = $alt_tag;