Here are two example PHP functions:
function myimage1() {
global $post;
$attachment_id = get_post_meta($post->ID, 'f1image', $single = true);
$myimage1 = wp_get_attachment_image( $attachment_id, thumbnail );
return $myimage1;
}
(I call this one like this: <?php echo myimage1(); ?> )
and
function myimage2() {
global $post;
$attachment_id = get_post_meta($post->ID, 'f1image', $single = true);
$myimage2 = wp_get_attachment_image( $attachment_id, medium );
return $myimage2;
}
(I call this one like this: <?php echo myimage2(); ?> )
As you can see, both have one common variable $attachment_id. And both functions are very much related, and it's just that I don't know how to combine them both, or how to call them from the combined function.
PS: I don't know PHP, my terminology could be a bit vague. In that case, please feel free to correct me.