voceconnect / multi-post-thumbnails

Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
143 stars 63 forks source link

MediaModal callback sometimes returns an array #82

Open gilbarbara opened 8 years ago

gilbarbara commented 8 years ago

Hello,

Thanks for this repo, it's a life saver! I'm having some errors in this new site that I'm working. If I remove the selected image and try to add it again I'm getting a WordPress alert with "Could not set that as the thumbnail image.."

I was trying to see what was going on and the MediaModal callback attachment parameter is an array instead of an object for the subsequent calls.

cb : function(attachment){
    MultiPostThumbnails.setAsThumbnail(attachment.id, "%2$s", "%1$s", "%4$s");
}

I was able to fix with attachment.id || attachment[0].id for setAsThumbnail