Ok, that helped me a lot. Now I understand, how it works.
But I have one issue: The Image is wrapped and if I doubleclick it, I get the thickbox etc. But if I click on “Attach” the thickbox doesn’t disappear and the image isn’t changed.
Can you help me one more time, please?
These are my class and function:
// Handles the post thumbnail
class FEE_Field_Img_1 extends FEE_Field_Thumbnail {
function wrap( $html, $post_id, $post_thumbnail_id, $size ) {
if ( !$post_id = $this->_get_id( $post_id, false ) )
return $html;
return FEE_Field_Base::wrap( $html, compact( 'post_id', 'size' ) );
}
function get( $data ) {
extract( $data );
return get_post_meta( $post_id, '_fit_profile_img_1', true );
}
function save( $data, $thumbnail_id ) {
extract( $data );
if ( -1 == $thumbnail_id ) {
delete_post_meta( $post_id, '_fit_profile_img_1' );
return -1;
}
update_post_meta( $post_id, '_fit_profile_img_1', $thumbnail_id );
list( $url ) = image_downsize( $thumbnail_id, $size );
return $url;
}
}
function fit_get_img_1( $post_id = NULL, $size = 'post-thumbnail', $attr = '' ) {
global $id;
$post_id = ( NULL === $post_id ) ? $id : $post_id;
$post_thumbnail_id = get_post_meta( $post_id, '_fit_profile_img_1', true );
if ( $post_thumbnail_id ) {
$html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
} else {
$html = '';
}
return apply_filters( 'editable_img_1', $html, $post_id, $post_thumbnail_id, $size );
}
And this is, what I register:
'editable_img_1' => array(
'title' => __( 'Profile image 1', 'front-end-editor' ),
'class' => 'FEE_Field_Img_1',
'type' => 'thumbnail',
'argc' => 4
)