Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You can get a false return because the update data is the same as what is already in place. This can happen when the call to update_post_meta() returns false. Another possible cause is that getting the attachment post failed due to a race condition. Eventually the post will be properly in place, but the get_post() call executed too soon after initial insertion.

    It’s not clear what causes your code to execute, but it could possibly execute more than once for the same file if it’s hooked to certain actions. The second time through, nothing had changed so false is returned.

    If you look at the source code for wp_generate_attachment_metadata(), when it calls wp_update_attachment_metadata() (line 581) it doesn’t bother to check the return value, perhaps because it can be misleading.

    Thread Starter chcw

    (@chcw)

    @bcworkz

    I see. Thank you very much.

    • This reply was modified 2 years, 3 months ago by chcw.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘wp_update_attachment_metadata always return false’ is closed to new replies.