wp_generate_attachment_metadata return value on errors (2 posts)

  1. taloweb
    Posted 2 years ago #

    Hello, in these days I worked with wp_generate_attachment_metadata function, it would be very useful if in case of some problems
    this function can return a WP_Error object and not an empty array.

    Example: if image doesn't exists or if attachment mime type is missing and in many other situation when wp_generate_attachment_metadata can't do its job, it simply fail returning an array without elements.

    What do you think about this?

  2. taloweb
    Posted 2 years ago #

    I found someone using this:

    $metadata = wp_generate_attachment_metadata( ID, $fullsizepath );
    if ( is_wp_error( $metadata ) )
    if ( empty( $metadata ))
    die (__( 'Unknown failure reason.'));

    but it's not documented that wp_generate_attachment_metadata can return a WP_error object...

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.