Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mhopps

    (@mhopps)

    Hello

    appreciate your reply

    No i didn’t use the add_image_size function – please see below the code i use

    $my_post = array();
    $my_post[‘post_title’] = $newid;
    $my_post[‘post_content’] = ”;
    $my_post[‘post_author’] = 1;
    $my_post[‘post_status’] = publish;
    $my_post[‘post_category’] = array($a);
    // Insert the post into the database
    $post_id = wp_insert_post($my_post);
    //
    $wp_filetype = wp_check_filetype(basename($config_basedir.$id), null );
    $attachment = array();
    $attachment[‘post_mime_type’] = $wp_filetype[‘type’];
    $attachment[‘post_title’] = $newid;
    $attachment[‘post_content’] = ”;
    $attachment[‘post_status’] = ‘inherit’;
    $attachment[‘post_type’] = ‘attachment’;
    $attach_id = wp_insert_attachment($attachment, $config_basedir.$id, $post_id);
    require_once(ABSPATH . ‘wp-admin/includes/image.php’);
    $attach_data = wp_generate_attachment_metadata($attach_id, $id . “.gif”);
    wp_update_attachment_metadata($attach_id, $attach_data);
    set_post_thumbnail($post_id, $attach_id);
    //
    wp_redirect( site_url().”?p=$post_id” ); exit();

    Thread Starter mhopps

    (@mhopps)

    Hello

    Ive managed to get the featured image to display on a post by changing the below within the single.php file (Hopefully that’s correct and wont break our else)

    <?php the_post_thumbnail(); ?> = Inserts the image with =1 height width
    to
    <?php the_post_thumbnail(‘my_feature_image’); = inserts full image

    The only issue now is within the post edit section
    http://postimg.org/image/4kopvo03f/
    From the pic above the featured image is set but for some reason it has height and width =1

    Ive deactivated all plugins and tried several themes but still the same

Viewing 2 replies - 1 through 2 (of 2 total)