wp_insert_attachment returns thumbs with resolution 1px (5 posts)

  1. paul91
    Posted 2 years ago #

    in my plugin I use function wp_insert_attachment. I use it in a standard way like here Those Thumbnails in Media Library which I added this way shows only with resolution 1 px, other thumbnails here shows normally. When I try to edit some of them by view post in Media library I see normal picture. I don't know what I made wrong. I am sure it workded previously well (probably before update to newer version?). Now I have version 3.8.1 and I tried it on 3 different servers with this version.
    My code is:

    $attachment = array(
        'post_mime_type' => 'image/jpeg',
        'post_title' => 'pic',
        'post_content' =>'',
        'post_status' => 'publish'
    $attach_id = wp_insert_attachment( $attachment,$upload_im);

    Any idea to works it?

  2. funkolector
    Posted 2 years ago #

    Same here.. weird.. did you find any solution?

  3. funkolector
    Posted 2 years ago #

  4. Justin Busa
    Posted 2 years ago #

    Have you considered trying media_handle_upload instead?


    Codex says this about wp_insert_attachment:

    This function is part of the low-level API used by WordPress for handling attachments. To perform the entire attachment upload and insertion process at once, you will want to use media_handle_upload() instead in most cases.

  5. funkolector
    Posted 2 years ago #

    Thank you :)

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.